// Arup Guha
// 1/18/07

// Use of multiple GiftCard objects and an illustration of references.

public class Shopping2 {
	
	public static void main(String[] args) {
	
		// Create two new gift card objects.
		GiftCard mine = new GiftCard("Arup", "Guha", 1000.00);
		GiftCard yours = new GiftCard("Poor", "Man", 2.00);	
		
		// Print out their information.
		System.out.println("My gift card: "+mine);
		System.out.println("Your gift card: "+yours);
		System.out.println();
		
		// Add more money to mine
		mine.addAmount(500.00);
		
		// Print out the cards again.
		System.out.println("After adding money, my gift card: "+mine);
		System.out.println("Your gift card is still: "+yours);
		System.out.println();
		
		// Use the compareTo method.
		if (mine.compareTo(yours) > 0)
			System.out.println("Ha ha! I have more money than you!");
			
		// Change the yours object.
		yours.spend(1.99);
		yours.transfer("John", "Doe");
		
		// Print out the changes.
		System.out.println("I am still rich: "+mine);
		System.out.println("Your gift card has changed: "+yours);
		System.out.println();
		
		// Create a new reference that refers to the same object as mine.
		GiftCard alias = mine;
		
		// Appears as if we made a copy of the object.
		System.out.println("I am still rich: "+mine);
		System.out.println("Your gift card: "+yours);
		System.out.println("Alias appears to be rich: "+ alias);
		System.out.println();
		
		// Spend money from the object to which alias refers.
		alias.spend(1450.00);
		
		// Proves that no real object copy was made.
		System.out.println("That bastard spent my money: "+mine);
		System.out.println("Your gift card: "+yours);
		System.out.println("Alias wins!: "+ alias);
		System.out.println();
		
		// Change where alias refers.
		alias = yours;
		alias.addAmount(59.99);
		
		// Print out these final values.
		System.out.println("I am still poor: "+mine);
		System.out.println("Your gift card has changed again: "+yours);
		System.out.println("Alias wins again!: "+ alias);
		
		
	}
	
}