Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Hwr10;
- public class PerosonDemo {
- public static void main(String[] args) {
- Person array[]=new Person[10] ;
- Person person1=new Person("Ivan",24,true);
- Person person2=new Person("Mariq",18,false);
- Student student1=new Student(4,"Nikolai",21,true);
- Student student2=new Student(5,"Teodor",21,true);
- Employee worker1=new Employee("Bai Ivan",45,true,10);
- Employee worker2=new Employee("Stefan",17,true,2);
- array[0]=person1;
- array[1]=person2;
- array[2]=student1;
- array[3]=student2;
- array[4]=worker1;
- array[5]=worker2;
- for(int y = 0;y<array.length-8;y++) {
- if(array[y] instanceof Employee) {
- System.out.println(worker1.calculateOvertime(1.8));
- System.out.println(worker2.calculateOvertime(1.8));
- }
- for(int i=0;i<array.length-4;i++) {
- if(array[i] instanceof Person) {
- System.out.println(person1.showPersonInfo());
- System.out.println(person2.showPersonInfo());
- }
- if(array[i] instanceof Student) {
- System.out.println(student1.showStudentInfo());
- System.out.println(student2.showStudentInfo());
- }
- if(array[i] instanceof Employee) {
- System.out.println(worker1.showEmployeeInfo());
- System.out.println(worker2.showEmployeeInfo());
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement