dm6801

171123 - Class 07 - Tester

Nov 26th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. package myApp;
  2.  
  3. public class test {
  4.  
  5.     public static void main(String[] args) {
  6.        
  7.         /* Adult class tester */
  8.         Adult p1 = new Adult("Person 1", 1.7, "Student");
  9.         p1.showSummary();
  10.        
  11.         Adult p2 = new Adult("Person 2", 1.8);
  12.         p2.showSummary();
  13.        
  14.         Adult p3 = new Adult(p1);
  15.         p3.showSummary();
  16.  
  17.         System.out.println("New updated information:");
  18.         p1.setName("Person 1.1");
  19.         p1.showSummary();
  20.         System.out.println();
  21.        
  22.        
  23.        
  24.         /* Rectangular class tester */
  25.         //create & print new object's details
  26.         Rectangular recObj1 = new Rectangular();
  27.         recObj1.details();
  28.        
  29.         //copy previous object to a new, 2nd object
  30.         Rectangular recObj_dup = new Rectangular(recObj1);
  31.         recObj_dup.details();
  32.        
  33.         //create 3rd object
  34.         Rectangular recObj2 = new Rectangular(23.1, 12);
  35.         recObj2.details();
  36.        
  37.         //change 3rd object's properties, print details
  38.         recObj2.setHeight(5);
  39.         recObj2.setWidth(13);
  40.         recObj2.details("   /__-> ");
  41.        
  42.         //print the object (width * char * height)
  43.         System.out.printf("%nPrinting (%s)...:%n", recObj2);
  44.         recObj2.print('z');
  45.        
  46.     }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment