game.rs 662 B

1234567891011121314151617181920212223242526272829303132
  1. // Objects
  2. pub struct Game {
  3. pub name: String,
  4. pub tickets: u32,
  5. pub tries: u32,
  6. pub prize: String,
  7. }
  8. const DEFAULT_TICKETS_TO_PLAY: u32 = 3;
  9. impl Game {
  10. pub fn new(name: String, tries: u32, prize: String) -> Game {
  11. Game {
  12. name,
  13. tickets: DEFAULT_TICKETS_TO_PLAY,
  14. tries,
  15. prize,
  16. }
  17. }
  18. }
  19. pub fn get_games() -> Vec<Game> {
  20. return vec![
  21. Game::new("Ring Toss".to_string(), 5, "teddy bear".to_string()),
  22. Game::new("I Got It!".to_string(), 12, "goldfish".to_string()),
  23. Game::new("Ladder Climb".to_string(), 1, "popcorn bucket".to_string()),
  24. ]
  25. }