Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. package Hwr10;
  2.  
  3. public class PerosonDemo {
  4.  
  5. public static void main(String[] args) {
  6. Person array[]=new Person[10] ;
  7. Person person1=new Person("Ivan",24,true);
  8. Person person2=new Person("Mariq",18,false);
  9. Student student1=new Student(4,"Nikolai",21,true);
  10. Student student2=new Student(5,"Teodor",21,true);
  11. Employee worker1=new Employee("Bai Ivan",45,true,10);
  12. Employee worker2=new Employee("Stefan",17,true,2);
  13. array[0]=person1;
  14. array[1]=person2;
  15. array[2]=student1;
  16. array[3]=student2;
  17. array[4]=worker1;
  18. array[5]=worker2;
  19. for(int y = 0;y<array.length-8;y++) {
  20. if(array[y] instanceof Employee) {
  21. System.out.println(worker1.calculateOvertime(1.8));
  22. System.out.println(worker2.calculateOvertime(1.8));
  23. }
  24. for(int i=0;i<array.length-4;i++) {
  25. if(array[i] instanceof Person) {
  26. System.out.println(person1.showPersonInfo());
  27. System.out.println(person2.showPersonInfo());
  28. }
  29. if(array[i] instanceof Student) {
  30. System.out.println(student1.showStudentInfo());
  31. System.out.println(student2.showStudentInfo());
  32. }
  33. if(array[i] instanceof Employee) {
  34. System.out.println(worker1.showEmployeeInfo());
  35. System.out.println(worker2.showEmployeeInfo());
  36. }
  37. }
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement