/*
Create an abstract Auto class with fields for the car make and price.
Include get and set methods for these fields; the setPrice() method is abstract.
Create two suclasses for individual automobile makers (for example, Ford and Chevy)
and include appropriate setPrice() methods in each subclass. Finally,
write a program that uses the Auto class and subclasses to display information about
different cars. The java programs should be named like:
Auto.java
Ford.java
Chevy.java
UseAuto.java
*/
public abstract class Auto
{
protected int price;
public int getPrice()
{
return price;
}
public abstract void setPrice();
}
public class Chevy extends Auto
{
public Chevy()
{
setPrice();
}
public void setPrice()
{
price = 10000;
}
}
public class Ford extends Auto
{
public Ford()
{
setPrice();
}
public void setPrice()
{
price = 5000;
}
}
public class UseAuto
{
public static void main(String[] args)
{
Ford ford = new Ford();
Chevy chevy = new Chevy();
System.out.println("The price of Ford car: " + ford.getPrice());
System.out.println("The price of Chevy car: " + chevy.getPrice());
}
}