Create a command line rock-paper-scissors game that prompts the player for a choice between rock, paper, or scissors; then randomizes the computer choice, and find out who's the winner. The program should keep track of the current round's winner, the player's score, the computer's score, and the number of games played.
- JavaScript
- Go
- Java
- Python
-
Make sure that GitHub Copilot is running in your editor by testing a short comment prompt:
// write a rock-paper-scissors game -
Get started writing code!
Please wait for the MCs to announce the start
Create a file to write your rock-paper-scissors game with an extension of your choice.
- The program prompts the user for an input between
rock,paper, orscissorsin the command line - The program randomizes the computer choice
- The program outputs the round's result after the user submits in the terminal the choice as follow:
Please input your choice >>> paper The computer chose: rock The player choice: paper The winner is: player Wins: 1 Losses: 0 Games played: 1 ======================== Please input your choice >>> ... - After each round, the game prompts the player for the new choice and the game continues until the program is closed
- The program checks for invalid user choice and asks the user to provide a valid input again. The program should not continue until the user provides a valid input.
Submission
- Capture the screenshot of the results and save it to the
/resultsfolder and name the file1.jpg. Example:/results/1.jpg - Commit and push your code to Git
Hopefully your Paper, Rock, Scissors game is working! Remember, GitHub Copilot is probabilistic so you may not get the exact same code suggestions as we did. If you're not happy with the suggestions, you can always press CTRL + Z to undo the changes and try again.
You're now ready to start the Level 2 Challenges to see how you can leverage the power of GitHub Copilot to solve more complex programming problems.
END OF LEVEL 1
Now you've had an opportunity to get started using GitHub Copilot, we have a number of challenges for you to attempt. Remember the goal here is not to test your programming abilities but rather, see how you can use GitHub Copilot to help you complete these tasks. Even if you've never done these programming tasks before, you may be surprised how Copilot can help you be successful with these challenges.
-
Improve the rock paper scissors game by adding Lizard and Spock. Refer to this chart for the updated game logic
-
Use the same CLI output from Chellenge #1
Extra Kudos for a terminal interface that provides a list of options with keyboard input. Eg.
$ Choose your option:
1. Rock
2. Paper
3. Scissors
4. Lizard
5. Spock
Submission
- Capture the screenshot of the results and save it to the
/resultsfolder and name the file3.jpg. Example:/results/3.jpg - Commit and push your code to Git
- Implement unit tests using using any testing module of your choice and capture the code coverage.
- Try to aim for over 80% coverage :)
Submission
- Capture the screenshot of the results and save it to the
/resultsfolder and name the file3.jpg. Example:/results/3.jpg - Commit and push your code to Git
💡 Tips: You might want to create a new file or folder for this challenge to keep your original code from Challenges 1-2.
-
Turn your program into a REST API
-
Sending a POST request (or json payload) should return a 200 OK response with the result in the body
Endpoint
POST /JSON Response - 200Request
{ "playerChoice": "paper" }Response
{ "computerChoice": "rock" "playerChoice": "paper" "winner": "player" "wins": 1 "losses": 0 "gamesPlayed": 1 } -
Should return a 400 BAD_REQUEST response error message in the body
Endpoint
POST /JSON Response - 400Request
{ "playerChoice": "" }Response
{ "message": "YOUR REASON HERE" }
Submission
- Capture the results and save it to the
/resultsfolder and name the file4.jpg. Example:/results/4.jpg - Commit and push your code to Git
END OF LEVEL 2