/**
 TemperatureDemo.java
 Test Driver program Class Temperature.
 
 Ref: #7,413,4th 
 AHD, Thurs 18th October 2007, 11:39 PT
 Please report any errors or omissions in this file.
*/
public class TemperatureDemo
{
    public static void main(String[] args)
    
    // The purpose of this main function is to test the
    // methods of the Temperature class. 
    // This type of program is known as a "driver" program, p291,3rd
    
   {
        // test each of the 4 constructors:
        Temperature t1 = new Temperature(); // calls default constructor
        Temperature t2 = new Temperature(37.0); // calls constructor with double argument
        Temperature t3 = new Temperature('F'); // calls constructor with char argument
        Temperature t4 = new Temperature(98.6, 'F'); // calls constructor with 2 arguments
        
        // now check contents of each object
        // to make sure constructors worked correctly
        
        System.out.println("These are the temperature objects: \n\n");
        t1.writeOutput( );
		t2.writeOutput( );
		t3.writeOutput( );
		t4.writeOutput( );
		
		System.out.println("Press any key to continue...\n\n");
		SavitchIn.readLine();
		double result = 0.0;
		
		System.out.println("Now testing temperature conversions...\n\n");
		// now checking the getCelciusTemperature() method
		result = t4.getCelsiusTemperature();
		System.out.println("Object t4's Celsius temperature is: " + result);
		
		
		// now checking the getFahrenheitTemperature() method
		result = t2.getFahrenheitTemperature();
		System.out.println("Object t4's Fahrenheit temperature is: " + result);
		
		System.out.println("\n\nResetting the values of the four objects t1, t2, t3, t4");
		t1.set(123.0);
		t2.set('F');
		t3.set(456.5,'C');
		t4.set(456.5,'C');
		
		// now checking the three overloaded set methods worked OK:
		System.out.println("These are the reset temperature objects: \n\n");
        t1.writeOutput( );
		t2.writeOutput( );
		t3.writeOutput( );
		t4.writeOutput( );
		
		System.out.println("Press any key to continue...\n\n");
		SavitchIn.readLine();
		
		// now checking if two object's temperatures are the same:
		System.out.println("\n\nNow comparing objects...\n\n ");
		if (t1.equals(t2))  
			System.out.println("The temperature of objects t1 and t2 are equal");
		else	
			System.out.println("The temperature of objects t1 and t2 are NOT equal");
			
		
		if (t3.equals(t4))
			System.out.println("The temperature of objects t3 and t4 are equal");
		else	
			System.out.println("The temperature of objects t3 and t4 are NOT equal");		
		
		
		if (t3.greaterThan(t4))  
			System.out.println("The temperature of object t3 is greater than t4.");
		else	
			System.out.println("The temperature of object t3 is NOT greater than t4.");	
			
			
		if (t3.lessThan(t4))
			System.out.println("The temperature of object t3 is less than t4.");
		else	
			System.out.println("The temperature of object t3 is NOT less than t4.");			
			
			
		System.out.println("\n\n\nPress any key to end this program...\n\n");
		SavitchIn.readLine();	
		System.out.println("\n\n\nPlease report any errors or omissions in this program...\n\n");
		SavitchIn.readLine();	
    }
}

