Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var firstPlayer, secondPlayer int
- fmt.Scanln(&firstPlayer)
- fmt.Scanln(&secondPlayer)
- var command string
- for {
- fmt.Scanln(&command)
- switch command {
- case "End":
- fmt.Printf("Player one has %d eggs left.\nPlayer two has %d eggs left.", firstPlayer, secondPlayer)
- os.Exit(0)
- case "one":
- secondPlayer--
- if secondPlayer == 0 {
- fmt.Printf("Player two is out of eggs. Player one has %d eggs left.", firstPlayer)
- os.Exit(0)
- }
- case "two":
- firstPlayer--
- if firstPlayer == 0 {
- fmt.Printf("Player one is out of eggs. Player two has %d eggs left.", secondPlayer)
- os.Exit(0)
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement