Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- public class Main {
- public static void main(String[] args) {
- Person[] persons = {
- new Employee("Ivan", 33, true, 70),
- new Employee("Ana", 28, false, 75),
- new Person("Peter", 40, true),
- new Person("Mariika", 36, false),
- new Student("Gosho", 20, true, 4.50),
- new Student("Penka", 19, false, 5.99)};
- for (Person person : persons) {
- if (person.getClass().getTypeName().endsWith("Person")) {
- person.showPersonInfo();
- } else if (person.getClass().getTypeName().endsWith("Student")) {
- person.showStudentInfo();
- } else {
- person.showEmployeeInfo();
- }
- }
- for (Person person : persons) {
- if (person.getClass().getTypeName().endsWith("Employee")) {
- System.out.println("Salary for overtime: " + person.calculateOvertime(2) + "lv.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment