Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

=+country competitive advantages? Why? Support your point of view.

Answered: 1 week ago