This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <cstdlib> | |
| #include <time.h> | |
| using namespace std; | |
| int main() { | |
| int choice, answer, difficulty, guesslimit, guesses; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::io::{self, Write}; | |
| fn main() { | |
| let mut name = String::new(); | |
| println!("Hello, world!"); | |
| println!("I'd like to greet you too! What's your name?"); | |
| get_input(&mut name); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use exitcode::ExitCode; | |
| #[derive(Debug, PartialEq, Eq)] | |
| struct AssignmentPair { | |
| first_pair: (usize, usize), | |
| second_pair: (usize, usize), | |
| } | |
| impl AssignmentPair { | |
| /// Returns an instance of AssignmentPair constructed from input. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| println!( | |
| "Write input below (Type 'EOF' to stop input):\ | |
| \n---------------" | |
| ); | |
| let input = input::capture_input(); | |
| println!("---------------"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| let mut input = String::new(); | |
| println!( | |
| "Write input below (Type 'EOF' to stop input):\ | |
| \n---------------" | |
| ); | |
| input::capture_input(&mut input); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use colored::Colorize; | |
| use std::{collections::HashSet, process::exit}; | |
| fn main() { | |
| let mut input = String::new(); | |
| println!( | |
| "Write input below (Type 'EOF' to stop input):\ | |
| \n---------------" | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum RoundResult { | |
| Win, | |
| Draw, | |
| Lost, | |
| } | |
| enum GameMove { | |
| Rock, | |
| Paper, | |
| Scissors, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum GameMove { | |
| Rock, | |
| Paper, | |
| Scissors, | |
| } | |
| impl GameMove { | |
| fn score(&self, opponent_move: GameMove) -> usize { | |
| match self { | |
| GameMove::Rock => match opponent_move { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use rprompt; | |
| use std::{ | |
| io::{stdout, Write}, | |
| process::exit, | |
| }; | |
| extern crate exitcode; | |
| fn main() { | |
| let mut input = String::new(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Company { | |
| name: String, | |
| employees: Vec<Employee>, | |
| employee_number: usize, | |
| } | |
| impl Company { | |
| fn new(name: &str, employees: Vec<Employee>) -> Company { | |
| Company { | |
| name: name.to_string(), |
NewerOlder