Advertisement
Guest User

tester

a guest
Mar 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. package person;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Collections;
  5.  
  6. import p2.Helper;
  7. import p2.Student;
  8.  
  9. public class Tester2 {
  10.  
  11.     public static void main(String[] args) {
  12.         // TODO Auto-generated method stub
  13.         Person p = new Person(1,"2");
  14.        
  15.         Student S = new Student(1, "DF",123);
  16.        
  17.         Double D = new Double(0.12);
  18.         double d1 = 0.1;
  19.         String s = "1234";
  20.         String s2 = "12343";
  21.        
  22.        
  23.         ArrayList<Helper> helpers = new ArrayList<>();
  24.        
  25.         Car c = new Car(100);
  26.        
  27.    
  28.        
  29.        
  30.         helpers.add(new Student(1, "asd", 1234));
  31.         helpers.add(new Student(2, "a1sd", 1234));
  32.         helpers.add(new Student(3, "a2sd", 1234));
  33.         helpers.add(new Student(1, "a3sd", 1234));
  34.         helpers.add(new Student(5, "as2d", 1234));
  35.         helpers.add(new Student(4, "as1d", 1234));
  36.         helpers.add(new Student(10, "as5d", 1234));
  37.        
  38.        
  39.        
  40.         System.out.println(helpers);
  41.        
  42.        
  43.         Collections.sort(helpers);
  44.        
  45.         System.out.println(helpers);
  46.        
  47.        
  48.         try {
  49.            
  50.            
  51.             if(helpers.get(0) instanceof Student)
  52.                 ((Student)helpers.get(0)).show(1);
  53.             else
  54.                 System.out.println("helpers.get(1) instanceof car");
  55.            
  56.         } catch (Exception e) {
  57.             System.out.println(e.getMessage());
  58.         }
  59.        
  60.        
  61.     }
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement