Advertisement
Spocoman

Easter Eggs Battle

Oct 7th, 2024 (edited)
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.86 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. func main() {
  6.     var firstPlayer, secondPlayer int
  7.     fmt.Scanln(&firstPlayer)
  8.     fmt.Scanln(&secondPlayer)
  9.    
  10.     var command string
  11.    
  12.     for {
  13.         fmt.Scanln(&command)
  14.         switch command {
  15.         case "End":
  16.             fmt.Printf("Player one has %d eggs left.\nPlayer two has %d eggs left.", firstPlayer, secondPlayer)
  17.             os.Exit(0)
  18.         case "one":
  19.             secondPlayer--
  20.             if secondPlayer == 0 {
  21.                 fmt.Printf("Player two is out of eggs. Player one has %d eggs left.", firstPlayer)
  22.                 os.Exit(0)
  23.             }
  24.         case "two":
  25.             firstPlayer--
  26.             if firstPlayer == 0 {
  27.                 fmt.Printf("Player one is out of eggs. Player two has %d eggs left.", secondPlayer)
  28.                 os.Exit(0)
  29.             }
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement