subject

Now, you will create additional classes that represent the different components of a car - the engine, the fuel tank, the wheels, etc. These classes should have methods related to their behaviors, and properties representing their various states (an engine is running or not, tires have levels of wear, etc). 1. Every class representing a car part should inherit from a superclass called "CarPart." The CarPart class will have at least the following states and behaviors:
2. condition - an integer that represents the remaining durability of the part (starts at 100, goes down to 0 when the part is broken)
3. status() - a method that prints the condition of the part to the console.
4. The CarPart class should also implement a Functional interface, which declares a method "function()".
5. Each subclass of CarPart should have at least one state unique to that part (like the number of cylinders in an engine, or the fuel level of a fuel tank). Each subclass should also implement the inherited function() method to print a unique message to the console that incorporates the variables unique to that class. The CarPart subclasses should not define unique methods, unless those methods are called from their overriden function() or status() methods.
6. Make sure that your Car class creates an instance of each CarPart subclass, as part of its constructor. These instances should be added to a collection of CarPart reference variables.
7. The run() method of your Car class should iterate through the Car's collection of CarPart references, which stores the instances of the CarPart subclasses. On each iteration, the function() method of the current object in the collection should be invoked.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:40
Adna sequence encoding a five-amino acid polypeptide is given below. …… …… locate the sequence encoding the five amino acids of the polypeptide, and identify the template and coding strand.
Answers: 1
question
Computers and Technology, 23.06.2019 16:30
20 points archie wants to use a reflector as he photographs a newlywed couple. what would he consider in his choice? a. shadow and sunny b. homemade and professional c. lamps and boards d. incident and reflected e. neutral density and enhancement
Answers: 3
question
Computers and Technology, 23.06.2019 20:00
How much current flows through the alternator brushes? a. 2–5 a b. 25–35 a, depending on the vehicle c. 5–10 a d. 10–15 a
Answers: 2
question
Computers and Technology, 24.06.2019 08:00
Can someone work out the answer as it comes up in one of my computer science exams and i don't understand the cryptovariables
Answers: 1
You know the right answer?
Now, you will create additional classes that represent the different components of a car - the engin...
Questions
question
History, 25.08.2019 17:30
question
Mathematics, 25.08.2019 17:30
question
Mathematics, 25.08.2019 17:30
question
History, 25.08.2019 17:30
Questions on the website: 13722362