public class Vehicle extends TaxableItem
{
	private double dealerCost;
	private double dealerMarkup;
	
	public Vehicle(double cost, double markup, double rate)
	{
		super(rate);
		dealerCost = cost;
		dealerMarkup = markup;
	}
	
	public static void main (String [] args)
	{
		System.out.println("\n\n\n");
		Vehicle nicecar = new Vehicle(10000, 2000, 0.05);
		System.out.println(nicecar.getListPrice());
		System.out.println(nicecar.purchasePrice());
		System.out.println();
		System.out.println();
		System.out.println();
		System.out.println("\n\n\n");
	}
	
	public double getListPrice ( )
	{
		return dealerCost + dealerMarkup;
	}
	
	public void changeMarkup(double markup)
	{
		dealerMarkup = markup;
	}
}

abstract class TaxableItem implements Item
{
	private double taxRate;
	
	public abstract double getListPrice();
	
	public TaxableItem(double rate)
	{
		taxRate = rate;
	}
	
	public double purchasePrice ( )
	{
		return getListPrice() * (1.0 + taxRate);
	}
}

interface Item
{
	double purchasePrice();
}

Back to APCS Main Page