// Inheritance: design practice
// Banana class

public class Banana
{
	private int numBitesLeft;
	private boolean isPeeled;
	
	public Banana()
	{
		numBitesLeft = 5;
		isPeeled = false;
	}
	
	// If banana is peeled, then eat a bite (return 0).
	// Else return 1.
	public int eat()
	{
		if (isPeeled && numBitesLeft>0) { numBitesLeft--; return 0; }
		return 1;
	}

	// Peel the banana, assuming it isn't already peeled.
	public int peel()
	{
		if (!isPeeled) { isPeeled = true; return 0; }
		return 1;
	}
	
	public String toString()
	{
		return "This banana " + (isPeeled? "is" : "isn't") + " peeled." +
						"  It has " + numBitesLeft + " bites left.";
	}
	
	public static void main(String[] args)
	{
		Banana b = new Banana();
		System.out.println("b is: " + b);
		System.out.println("Eating: " + b.eat() + " = " + b);
		System.out.println("Peeling: " + b.peel() + " = " + b);
		System.out.println("Eating: " + b.eat() + " = " + b);
		System.out.println("Peeling: " + b.peel() + " = " + b);
	}	
}