Quick Index
Code Explanation


Hello, my name is Car.

I implement the Taxable interface.

Note the "implements" keyword on the class header.

Read more about me below.

Three ivars for our simple class.
public class Car implements Taxable {
	private String make;
	private String model;
	private BigDecimal price;

	//etc (more code follows)

}
Note user-friendly type "String" for price.
Internally we use more complex BigDecimal
	public Car(String aMake, String aModel, String aPrice)  {
		this.make = aMake;
		this.model = aModel;
		this.price = new BigDecimal(aPrice);
	}
Because I (a Car) implement the Taxable idea, I must override "beforeTaxPrice" (Taxable requires me to).
	public BigDecimal beforeTaxPrice()  {
		return this.getPrice();
	}

Complete Source Code


Here is all my code.

Have Fun.

Later,
Car

package taxcalc.test;

import java.math.BigDecimal;

import taxcalc.model.Taxable;

public class Car implements Taxable {

	private String make;
	private String model;
	private BigDecimal price;

	public Car(String aMake, String aModel, String aPrice) {
		this.make = aMake;
		this.model = aModel;
		this.price = new BigDecimal(aPrice);
	}

	public String getMake() {
		return make;
	}

	public String getModel() {
		return model;
	}

	public BigDecimal getPrice() {
		return price;
	}

	@Override
	public BigDecimal beforeTaxPrice() {
		return this.getPrice();
	}

}