update,
This commit is contained in:
17
_resources/it114105/itp3914/Lab12/Ex2/Employee.java
Normal file
17
_resources/it114105/itp3914/Lab12/Ex2/Employee.java
Normal file
@@ -0,0 +1,17 @@
|
||||
public class Employee {
|
||||
public static final int MIN_ID = 1000;
|
||||
protected String name;
|
||||
protected int employeeID;
|
||||
|
||||
public Employee(String n, int id) {
|
||||
name = n;
|
||||
if (id < MIN_ID)
|
||||
employeeID = 0;
|
||||
else
|
||||
employeeID = id;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Name: " + name + ", ID: " + employeeID;
|
||||
}
|
||||
}
|
9
_resources/it114105/itp3914/Lab12/Ex2/Ex2.java
Normal file
9
_resources/it114105/itp3914/Lab12/Ex2/Ex2.java
Normal file
@@ -0,0 +1,9 @@
|
||||
public class Ex2 {
|
||||
public static void main(String [] args) {
|
||||
Employee emp = new Employee("John", 31520);
|
||||
FTEmployee ftemp = new FTEmployee("Mary", 42680, 15000.5);
|
||||
|
||||
System.out.println(emp);
|
||||
System.out.println(ftemp);
|
||||
}
|
||||
}
|
11
_resources/it114105/itp3914/Lab12/Ex2/FTEmployee.java
Normal file
11
_resources/it114105/itp3914/Lab12/Ex2/FTEmployee.java
Normal file
@@ -0,0 +1,11 @@
|
||||
public class FTEmployee extends Employee {
|
||||
double salary;
|
||||
FTEmployee(String name, int employeeID, double salary){
|
||||
super(name, employeeID);
|
||||
this.salary = salary;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return super.toString() + ", Salary: " + salary;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user