binibiningtinamoran

TestTemp

Oct 25th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. public class TestTemp
  2. {
  3.     public static void main(String[] args)
  4.     {
  5.         // testing constructors and set methods
  6.         Temperature temp1 = new Temperature(0.0, 'C');
  7.         Temperature temp2 = new Temperature(32.0, 'F');
  8.         Temperature temp3 = new Temperature(-40.0);
  9.         temp3.setScale('C');
  10.         Temperature temp4 = new Temperature('F');
  11.         temp4.setDegrees(-40.0);
  12.         Temperature temp5 = new Temperature();
  13.         temp5.setInfo(100.0, 'C');
  14.         Temperature temp6 = new Temperature(212.0, 'F');
  15.         // testing fahrenheit/celsius conversion
  16.         System.out.println(temp1.returnFahrenheit()); //32
  17.         System.out.println(temp2.returnCelsius()); //0
  18.  
  19.         // testing get methods
  20.         System.out.println(temp1.getTemperature()); //0
  21.         System.out.println(temp1.getScale()); //C
  22.         temp5.equalize(temp6);
  23.         temp5.writeOutput(); // should return 100.0, C
  24.         temp5.writeOutput(); // should return 212.0, F
  25.  
  26.         // testing comparison methods
  27.         temp6.setInfo(212.0, 'F');
  28.         System.out.println(temp1.equals(temp2)); //should return T : error when equalize not working
  29.         System.out.println(temp3.equals(temp4)); //should return T
  30.         System.out.println(temp5.equals(temp5)); //should return T
  31.         System.out.println(temp1.equals(temp6)); //should return F
  32.         System.out.println(temp2.equals(temp4)); //should return F
  33.  
  34.         System.out.println(temp1.isGreaterThan(temp6)); //should return F
  35.         System.out.println(temp2.isGreaterThan(temp4)); //should return T
  36.         System.out.println(temp1.isLessThan(temp6)); //should return T : error when equalize not working
  37.         System.out.println(temp2.isLessThan(temp4)); //should return F
  38.     }
  39. }
Add Comment
Please, Sign In to add comment