Use the supplied superclass Car to create the following classes. Ford, Chevy, To
ID: 3533709 • Letter: U
Question
Use the supplied superclass Car to create the following classes. Ford, Chevy, Toyota.
Because Toyotas are superior to Fords or Chevys it should also implement the supplied Airplane interface. Give the methods something to do. I would suggest a println method since you can then see that the method actually ran.
You will need to write a test class in order to check the behavior of your created classes. Instantiate objects of each one of your classes and invoke the methods of those objects.
The implementation for the getResaleValue method from the Car class will be different for Ford, Chevy and Toyota. Use the following formulas;
Ford
Resale value =$15,000
Explanation / Answer
Here you go;
Toyota.java
public class Toyota extends Car implements Airplane{
public Toyota(int s,String c,int m)
{
super(s,c,m);
}
@Override
public void takeoff() {
System.out.println("Took off !!");
}
@Override
public void fly() {
System.out.println("Flew !!");
}
@Override
public void land() {
System.out.println("Landed !!");
}
@Override
public boolean equals(Object o) {
// TODO Auto-generated method stub
return false;
}
@Override
public double getResaleValue()
{
if(getMiles()>=200000)
{
return 15000+10000;
}
else
{
return (15000-(0.035*getMiles()));
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.