corejava第10版
This commit is contained in:
1 parent
2021c3c227
commit
6165543dd3
1088 files changed
+94411
No files matched your search
@@ -0,0 +1,28 @@
|
||||
package inheritance;
|
||||
|
||||
/**
|
||||
* This program demonstrates inheritance.
|
||||
* @version 1.21 2004-02-21
|
||||
* @author Cay Horstmann
|
||||
*/
|
||||
public class ManagerTest
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// construct a Manager object
|
||||
Manager boss = new Manager("Carl Cracker", 80000, 1987, 12, 15);
|
||||
boss.setBonus(5000);
|
||||
|
||||
Employee[] staff = new Employee[3];
|
||||
|
||||
// fill the staff array with Manager and Employee objects
|
||||
|
||||
staff[0] = boss;
|
||||
staff[1] = new Employee("Harry Hacker", 50000, 1989, 10, 1);
|
||||
staff[2] = new Employee("Tommy Tester", 40000, 1990, 3, 15);
|
||||
|
||||
// print out information about all Employee objects
|
||||
for (Employee e : staff)
|
||||
System.out.println("name=" + e.getName() + ",salary=" + e.getSalary());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user