0

Please help me finish my code, I am super confused and if someone can walk me through this.

Create a Java project in eclipse, called "PracticeCar" Create a class called "Simulator", with a main() method. Create a "Car" class, with a run() method. Inside the main() method of Simulator, create an instance of a Car object, and invoke that object's run() method. 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). 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: condition - an integer that represents the remaining durability of the part (starts at 100, goes down to 0 when the part is broken) status() - a method that prints the condition of the part to the console. The CarPart class should also implement a Functional interface, which declares a method "function()". 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. 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. 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. here is my code so far package myCar; class car { public void run() {

15th Apr 2020, 2:22 PM
Graison Youngboys Barthelus
Graison Youngboys Barthelus - avatar
2 ответов
+ 1
Please save your code in SoloLearn, and share just the link of the saved code. Copy pasting raw text code like this isn't as practical, as your code risk from being truncated from character limits. Follow this guide about how to share links https://www.sololearn.com/post/75089/?ref=app
15th Apr 2020, 2:35 PM
Ipang
- 1
my code so far! i need help implementing interface and adding methods to extended class. thank you in advance. package myCar; class car { public void run() { System.out.println("Vroom! "); } } public class Simulator { public static void main(String []args) { car lexus=new car(); lexus.run(); } } class CarPart{ public void functional() { } } class engine extends CarPart{ } class fuelTank extends CarPart{ } class tires extends CarPart{ }
15th Apr 2020, 2:23 PM
Graison Youngboys Barthelus
Graison Youngboys Barthelus - avatar