Write a java console project - create a class called car -


Write a java console project, call it GameCar.

Create a class called car.

A. This class should have the following four public attributes: integer carId, String carName, integer racePosition, and String carModel.
B. This class should have a constructor which will take 3 parameters: integer carId, String carName, and String carModel. (Except racePosition, which will be generated in car game)
C. This class should have a Display method, to display the following information in a new row: "carName" is ranked "racePosition", Model is "carModel"

4.2 Create an Interface called gameInterface, in this interface, create an abstract method called "gameStart(int numberOfRounds)"

4.3 Create a class call carGame
A. This class should have one private member call "carList", which is an array of car objects.
B. This class should have one constructor, which will initialize "carList" for all 5 car objects. When you do initialization, each car in the carList, must have a unique carId (0-4), unique carName (For example John's Mustang), and unique carModel picked from the following 5 models ("Mustang", "Nissian_370Z", "BMW_M3", "Audi_R8", "Porsche_911")
C. This carGame should have a method called Display(), inside this method, you should use a for-loop to call each car's Display() method. Since car.Display() will display one row for this car, carGame.Display() will display all 5 cars' information in 5 rows.
D. Your carGame class must implement the gameInterface, you should implement the gameStart(int numberOfRounds) method. This method takes one parameter: integer numberOfRounds to decide how many rounds this game will run. Inside this method, you should have nested for-loops. The outside for-loop runs numberOfRounds, the inside for-loop assigns a random number between 1-5 to each car's racePosition. In the outside for-loop, for each round, you should call carGame.Display, to display the current round's car positions.

4.4 In your main function, you should create a new carGame object. Then call it's gameStart method, and pass in the parameters in the following way: carGame.gameStart(5). This will make the carGame run 5 rounds.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write a java console project - create a class called car -
Reference No:- TGS02394939

Now Priced at $10 (50% Discount)

Recommended (97%)

Rated (4.9/5)