1 Star 1 Fork 0

CS-IMIS-23/20172313yukunpeng

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Staff.java 1.94 KB
一键复制 编辑 原始数据 按行查看 历史
package srcNo8;
//********************************************************************
// Staff.java Author: Lewis/Loftus
//
// Represents the personnel staff of a particular business.
//********************************************************************
public class Staff {
private StaffMember[] staffList;
//-----------------------------------------------------------------
// Constructor: Sets up the list of staff members.
//-----------------------------------------------------------------
public Staff() {
staffList = new StaffMember[6];
staffList[0] = new Executive("Sam", "123 Main Line",
"555-0469", "123-45-6789", 2423.07);
staffList[1] = new Employee("Carla", "456 Off Line",
"555-0101", "987-65-4321", 1246.15);
staffList[2] = new Employee("Woody", "789 Off Rocker",
"555-0000", "010-20-3040", 1169.23);
staffList[3] = new Hourly("Diane", "678 Fifth Ave.",
"555-0690", "958-47-3625", 10.55);
staffList[4] = new Volunteer("Norm", "987 Suds Blvd.",
"555-8374");
staffList[5] = new Volunteer("Cliff", "321 Duds Lane",
"555-7282");
((Executive) staffList[0]).awardBonus(500.00);
((Hourly) staffList[3]).addHours(40);
}
//-----------------------------------------------------------------
// Pays all staff members.
//-----------------------------------------------------------------
public void payday() {
double amount;
for (int count = 0; count < staffList.length; count++) {
System.out.println(staffList[count]);
amount = staffList[count].pay(); // polymorphic
if (amount == 0.0)
System.out.println("Thanks!");
else
System.out.println("Paid: " + amount);
System.out.println("-----------------------------------");
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/CS-IMIS-23/20172313yukunpeng.git
git@gitee.com:CS-IMIS-23/20172313yukunpeng.git
CS-IMIS-23
20172313yukunpeng
20172313yukunpeng
master

搜索帮助