// Rock-Paper-Scissors -- starter. // // See the chapter page (project-rock-paper-scissors.html) for the full spec. // // As it is, the file reads your move and prints one placeholder line. // When you pick the computer's move, add "math/rand" to the import list. // // Run with: go run projects/rock-paper-scissors/starter.go package main import ( "bufio" "fmt" "os" "strings" ) func main() { reader := bufio.NewReader(os.Stdin) fmt.Print("Choose rock, paper, or scissors: ") text, _ := reader.ReadString('\n') player := strings.TrimSpace(text) // TODO 1: pick the computer's move at random with rand.Intn(3) + 1 and // turn the number into "rock", "paper", or "scissors" with a switch. // Declare the computer variable before the switch. // TODO 2: print what the computer chose. // TODO 3: decide the result with if, else if, else: // - not a valid choice // - a tie (same move) // - you win (rock beats scissors, paper beats rock, scissors beats paper) // - otherwise you lose // Replace this placeholder line: fmt.Println("TODO: replace this line", player) }