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. Then, create a GUI application (extending from JFrame) where each player can 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. The game should display 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

=========================================================================

This is what I have so far....I only did the car class...having trouble running a demo class:

public class Car { //declare fields private String make; private String model; private double quarterMileTime; //constructor public Car(String make, String model) { super(); this.make = make; this.model = model; getQuarterMileTime(); } //getters and setters public String getMake(){ return make; } public String getModel(){ return model; } public double getQuarterMileTime(){ quarterMileTime =( Math.random()*10) + 1; return quarterMileTime; } //toString @Override public String toString() { return "Car [make: " + make + ", model: " + model + ", time: " + quarterMileTime + "]"; } }

Thanks in advance for your help!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!