LabWork 5
LabWork 5
Lab Work 5
- To use polymorphism properties, create an ArrayList of Vehicle class, and add all objects of its
derived classes; Iterate through the elements of the list and, for each iteration, call the displayInfo
method from the current object.
Write a Person class with attributes (name, birthDate, address), and a Student class that inherits from the
Person class. A student is characterized by (specialty, level). Write an Employee class that also inherits from
the Person class and is characterized by (position, baseSalary, bonus). All classes must contain an overridden
displayInfo() method to display the object's information. The Employee class contains a calculateSalary()
method to calculate the net salary using the formula: Salary = baseSalary + bonus – (baseSalary * 0.09).
Similarly, the Student class contains a calculateAge(int currentYear) method to return the student's age, with
the current year as a parameter.
Here are the following declarations:
p.displayInfo() ;