+ 1
Help me Abstraction please
How create on abstract auto class with field for the car name and price. Then include get and set methods these feilds. And tha setprice() method is abstract. Ans create two subclasses for individual automobile makers(for example,Ford and Jeep) and include oppropriate setprice() metods in each subclass.
2 ответов
+ 1
abstract public class Car {
protected double price ;
protected String name ;
abstract public void setPrice ( double price ) ;
public double getPrice ( ) {
return this.price ;
}
public String getName ( ) {
return this.name ;
}
public void setName ( String name ) {
this.name = name ;
}
}
public class Ford extends Car {
public void setPrice ( double price ) {
this.price = price * 1.2 ;
}
}
public class Jeep extends Car {
public void setPrice ( double price ) {
this.price = price * 0.8 ;
}
}
+ 1
Thank you very much