- Person class
Create a Person class that implements the above methods. A person should have a last name and an address. It should also be possible to display this information using the toString() method.
- Student class
Create a Student class that implements the above methods. Student must have a program, a year and fee. It should also be possible to display this information using the toString() method.
- Staff class
Create a Staff class that implements the above methods. Staff must have a school name (School) and a salary (pay). It should also be possible to display this information using the toString() method.
package person;
public class Person {
private String last_name, address;
public String toString(){
return "Last name: "+ last_name+"\nAddress: "+address+"\n";
}
public static void main(String[] args) {
}
}
class Student{
private String program;
private int year;
private double fee;
public String toString(){
return "Program: "+ program+"\nYear: "+year+"\nFee: "+ fee+"\n";
}
}
class Staff{
private String school_name;
private double salary;
public String toString(){
return "School name: "+ school_name+"\nSalary: "+salary+"\n";
}
}
Comments
Leave a comment