The CarPart class should also implement a Functional interface, which declares a method "function()".< ------ This is an instruction which I am trying to do but it is not working. Please help
public class Simulator {
public static void main(String[] args) {
// TODO Auto-generated method stub
Car mycar = new Car("Red");
mycar.run();
CarPart my_car_part = new CarPart();
my_car_part.status(90);
Engine my_engine = new Engine(true);
my_engine.status(100);
my_engine.function();
}
}
class Car{
private String color = " ";
public Car(String n_color)
{
this.color = n_color;
}
public void run() {
System.out.println("This can can run");
}
}
class CarPart
{
public interface myinterface{
public void function();
}
public static final int MAX = 100;
public static final int MIN = 0;
int condition;
public CarPart()
{
this.condition = MAX;
}
public void status(int n_condition)
{
condition = n_condition;
if(condition == MAX )
{
System.out.println("Brand new part");
}
else if (condition <100 && condition > 80)
{
System.out.println("Fairly new part");
}
else if(condition <= 80 && condition > 40)
{
System.out.println("ok part");
}
else if(condition <= 40 && condition > 0)
{
System.out.println("old Part");
}
else if (condition == 0)
{
System.out.println("Not working Part");
}
else
{
System.out.println("Invalid Input");
}
//System.out.println("update satus");
}
}
class Engine extends CarPart implements myinterface {
//private String engine_type = " ";
private boolean engineState = false;
private int engine_horse_power = 100;
public Engine( boolean n_engineState) {
super();
this.engineState = n_engineState;
if(engineState == true)
{
engineSound();
}
else
{
System.out.println("Engine is dead");
}
}
public void function()
{
}
--- Update ---
Never mind, I found the problem. Thanks