Question: Create a basic car racing game (no graphics necessary). Using the UML diagram below, create a bet class, a player class (two players), and a
Create a basic car racing game (no graphics necessary). Using the UML diagram below, create a bet class, a player class (two players), and a car class (four cars). Create a demo class for the three classes. For input, each player should be able to select a vehicle and place a wager (capped at $100). The game should be able to run until one player has $0 remaining or until the user wants to quit. For example, (both players initialized with $100 in bet money) if in round one player 1 wagers $20 and player 2 wagers $30, and player 1 loses the round, player 1 will have $100 - $20(player 1's lost wager)= $80 and player 2 will have $100 + $20(player 1's lost wager). Rounds will repeat until the game should theoretically end when one player has $200 or until the user quits the program. The game should display (output) who won (player one or player two)
Variables
Player1
Player2
Player1 Bet
Player2 Bet
Cars quarterMileTime
vehicleOne 14.7s
vehicleTwo 13.7s
vehicleThree 14.0s
vehicleFour 13.9s
UML DIAGRAM:
Racing Game
Bet ---------- player1 : Player player2 : Player wager : int ---------- +Bet( player1, player 2 : Player, wager : int ) +Race() : String
Player ---------- -name : String -cash : int -vehicle : Car ----------- +getName() : String +getCash() : int +addCash( int cash ) : int +setVehicle( Car car ) : void
+getVehicle() : Car
Car ----- -make : string -model : string ---- +getQuarterMileTime() : double - make this random < 10 seconds +getMake() : String +getModel() : String +toString() : String
GUI screen -Player 1 select a car ( radio button? ) -total cash ( starts at 100 ) -Player 2 select a car ( radio button? ) -total cash ( starts at 100 )
-Text box for wager -button for Place Bet -button for Race
display race result -If player 1 wins, cash goes up, player 2 cash goes down
Game ends when one player has <= 0 cash
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
