Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonocarroll/rps.rs
Rock, Paper, Scissors game, demonstrating enums
https://github.com/jonocarroll/rps.rs
Last synced: 8 days ago
JSON representation
Rock, Paper, Scissors game, demonstrating enums
- Host: GitHub
- URL: https://github.com/jonocarroll/rps.rs
- Owner: jonocarroll
- Created: 2023-06-23T09:18:46.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-23T23:52:24.000Z (over 1 year ago)
- Last Synced: 2024-11-15T14:43:00.944Z (2 months ago)
- Language: Rust
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rps
Play rock ๐ชจ, paper ๐งป, scissors โ๏ธ against the computer
Demonstrates uses of `enum`
## Examples
```rust
cargo run -q
Let's play! ๐ชจ๐งปโ๏ธ
What do you throw?
rock
You threw... Rock ๐ชจ
Computer throws Rock ๐ชจ
Result: It's a tie! ๐
Press ENTER to play again, or anything else to quitLet's play! ๐ชจ๐งปโ๏ธ
What do you throw?
paper
You threw... Paper ๐งป
Computer throws Scissors โ๏ธ
Result: Sorry, you lose ๐ฟ
Press ENTER to play again, or anything else to quitLet's play! ๐ชจ๐งปโ๏ธ
What do you throw?
scissors
You threw... Scissors โ๏ธ
Computer throws Paper ๐งป
Result: You win, congrats! ๐
Press ENTER to play again, or anything else to quit
```A single argument can also be passed to play just once
```rust
cargo run -q -- rock
Let's play ๐ชจ๐งปโ๏ธ!
You threw... Rock ๐ชจ
Computer throws Rock ๐ชจ
Result: It's a tie! ๐
```