Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
OUTPUT:
Mercedes W13 is moving...
Out of gas!
Mercedes W13 has travelled 260.0 kilometers
Red Bull RB16 is moving...
Out of gas!
Red Bull RB16 has travelled 300.0 kilometers
Ferrari F1-75 is moving...
Out of gas!
Ferrari F1-76 has travelled 280.0 kilometers
McLaren MCL36 is moving...
Out of gas!
McLaren MCL36 has travelled 270.0 kilometers
Aston Martin AMR22 is moving...
Out of Gas!
Acton Martin AMR22 has travelled 272.0 kilometers
The winner is Red Bull RB16
Transcribed Image Text:OUTPUT: Mercedes W13 is moving... Out of gas! Mercedes W13 has travelled 260.0 kilometers Red Bull RB16 is moving... Out of gas! Red Bull RB16 has travelled 300.0 kilometers Ferrari F1-75 is moving... Out of gas! Ferrari F1-76 has travelled 280.0 kilometers McLaren MCL36 is moving... Out of gas! McLaren MCL36 has travelled 270.0 kilometers Aston Martin AMR22 is moving... Out of Gas! Acton Martin AMR22 has travelled 272.0 kilometers The winner is Red Bull RB16
MAKE A JAVA PROGRAM
A class hierarchy or inheritance tree in computer science is a classification of object types,
denoting objects as the instantiations of classes inter-relating the various classes by
relationships such as "inherits", "extends", "is an abstraction of", "an interface definition".
Write a java program with a class hierarchy using the following classes:
Vehicle
Car
Racecar
In the Vehicle class, create the fields called currentLitersOfGasInTank, kilometersPerLiter,
and totalKilometersTravelled , all of type double.
In the Car class, create the methods consumeGas(), and moveUntilNoMoreGas(), both
having a return type of void.
ConsumeGas() - this method decrements the currentLitersOfGasInTank field by 1 every time
it is called.
moveUntilNoMoreGas) - this method calls consumeGas) and then increments
totalKilometersTravelled by whatever the value of kilometersPerLiter is. When
currentLitersOfGasInTank is 0, it will print "Out of gas".
In the Racecar class, create a string field called raceCarName.
Create another class, RacingSimulator with a static field named carsToRace, which is an
ArrayList of Racecars. In this RacingSimulator class, create a static method called race(),
which will call each of the racecar's moveUntilNoMoreGas() method. If two or more cars
have the same values for currentLitersOfGasInTankand totalKilometersTravelled, then those
cars will obviously have the same totalKilometersTravelled. In this case, just pick any ofthose
cars as the winner.
In your main method, create 5 instances of a Racecar. Initialize the values of raceCarName,
currentLitersOfGasInTank and totalKilometersTravelled to be whatever you want for each
race car. Add the 5 Racecar objects to the carsToRace field of RacingSimulator, and call
RacingSimulator.race(; Your program should print the raceCarName ofthe car that travelled
the most kilometers. Obviously, it should be the car that has the highest value for
totalKilometersTravelled.
Transcribed Image Text:MAKE A JAVA PROGRAM A class hierarchy or inheritance tree in computer science is a classification of object types, denoting objects as the instantiations of classes inter-relating the various classes by relationships such as "inherits", "extends", "is an abstraction of", "an interface definition". Write a java program with a class hierarchy using the following classes: Vehicle Car Racecar In the Vehicle class, create the fields called currentLitersOfGasInTank, kilometersPerLiter, and totalKilometersTravelled , all of type double. In the Car class, create the methods consumeGas(), and moveUntilNoMoreGas(), both having a return type of void. ConsumeGas() - this method decrements the currentLitersOfGasInTank field by 1 every time it is called. moveUntilNoMoreGas) - this method calls consumeGas) and then increments totalKilometersTravelled by whatever the value of kilometersPerLiter is. When currentLitersOfGasInTank is 0, it will print "Out of gas". In the Racecar class, create a string field called raceCarName. Create another class, RacingSimulator with a static field named carsToRace, which is an ArrayList of Racecars. In this RacingSimulator class, create a static method called race(), which will call each of the racecar's moveUntilNoMoreGas() method. If two or more cars have the same values for currentLitersOfGasInTankand totalKilometersTravelled, then those cars will obviously have the same totalKilometersTravelled. In this case, just pick any ofthose cars as the winner. In your main method, create 5 instances of a Racecar. Initialize the values of raceCarName, currentLitersOfGasInTank and totalKilometersTravelled to be whatever you want for each race car. Add the 5 Racecar objects to the carsToRace field of RacingSimulator, and call RacingSimulator.race(; Your program should print the raceCarName ofthe car that travelled the most kilometers. Obviously, it should be the car that has the highest value for totalKilometersTravelled.
Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY