Java Programming

computer science

Description

Race Cars"

Construct a calli ng class and a Car class as follows:-' Car Class:-'

Properties: Ma ke (String), Year(int), Color(String), Speed (int)-' Methods:  "

  •    All getter, setter methods"
  •     Accel erate ( increase speed : 15MPH if year < 2010, 30 MPH >= 2010}-'
  •     Brake ( lower speed : SMPH if year < 2010, 10 MPH >= 2010, speed always >=0)-'
  •     Stop (speed = 0)-'

 

Calling Class-'

Create an array of 10 cars. Give them random colors and makes your choice. Select a random year for a car, but when done, half the cars should have a year >=2010.  Initial Speed is zero.-' Do the following 100 times-'

  •     Pick a random car-'
  •     Randomly select Brake, Accelerate  or Stop method  (equal probabilities)-'
  •     Invoke the selected method chosen for the car chosen-'

After the loop, print out the card number, year, make, color and final speed."

 

Extra Credit {2 point:}-'

Simulate a race.   Each car starts at zero. Make a loop where the body of the loop does the three bullet points above. However, in this part, each iteration of the loop represents one minute of time. After each iteration of the loop, calculate the distance traveled by car. Keep track of each car's total distance. When a car reaches 100 miles, it is the winner. Print out the winning car, the second place car (based  on distance) and distance,.....till the last place car.-'

Instruction Files

Related Questions in computer science category


Disclaimer
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.