Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TestPerson {
- public static void main(String[] args) {
- Person person = new Person("John Doe", "123 Somewhere", "415-555-1212", "johndoe@somewhere.com");
- Person student = new Student("Mary Jane", "555 School Street", "650-555-1212", "mj@abc.com", "junior");
- Person employee = new Employee("Tom Jones", "777 B Street", "40-88-889-999", "tj@xyz.com");
- Person faculty = new Faculty("Jill Johnson", "999 Park Ave", "92-52-22-3-333", "jj@abcxyz.com");
- Person staff = new Staff("Jack Box", "21 Jump Street", "707-21-2112", "jib@jack.com");
- System.out.println(person.toString() + "n");
- System.out.println(student.toString() + "n");
- System.out.println(employee.toString() + "n");
- System.out.println(faculty.toString() + "n");
- System.out.println(staff.toString() + "n");
- }
- }
- public class TestPerson {
- public static void main(String[] args) {
- Person person = new Person("John Doe", "123 Somewhere", "415-555-1212", "johndoe@somewhere.com");
- Person student = new Student("Mary Jane", "555 School Street", "650-555-1212", "mj@abc.com", "junior");
- Person employee = new Employee("Tom Jones", "777 B Street", "40-88-889-999", "tj@xyz.com");
- Person faculty = new Faculty("Jill Johnson", "999 Park Ave", "92-52-22-3-333", "jj@abcxyz.com");
- Person staff = new Staff("Jack Box", "21 Jump Street", "707-21-2112", "jib@jack.com");
- System.out.println(person.toString() + "n");
- System.out.println(student.toString() + "n");
- System.out.println(employee.toString() + "n");
- System.out.println(faculty.toString() + "n");
- System.out.println(staff.toString() + "n");
- }
- }
- public class Person {
- private String name;
- private String address;
- private String phone_number;
- private String email_address;
- public Person() {
- }
- public Person(String newName, String newAddress, String newPhone_number, String newEmail){
- name = newName;
- address = newAddress;
- phone_number = newPhone_number;
- email_address = newEmail;
- }
- public void setName(String newName){
- name = newName;
- }
- public String getName(){
- return name;
- }
- public void setAddress(String newAddress){
- address = newAddress;
- }
- public String getAddress(){
- return address;
- }
- public void setPhone(String newPhone_number){
- phone_number = newPhone_number;
- }
- public String getPhone(){
- return phone_number;
- }
- public void setEmail(String newEmail){
- email_address = newEmail;
- }
- public String getEmail(){
- return email_address;
- }
- public String toString(){
- return "Name :"+getName();
- }
- }
- public class Student extends Person {
- public final String class_status;
- public Student(String name, String address, int phone, String email, String classStatus) {
- super(name, address, phone, email);
- class_status = classStatus;
- }
- public String toString(){
- return "Student Status: " + super.getName();
- }
- }
- import java.util.Date;
- public class Employee extends Person{
- private String office;
- private double salary;
- private Date hire;
- public Employee() {
- }
- public Employee(String name, String address, int phone, String email){
- super(name, address, phone, email);
- }
- public Employee(String office, double salary, Date hire){
- this.office = office;
- this.salary = salary;
- this.hire = hire;
- }
- public void setOffice(String office){
- this.office = office;
- }
- public String getOffice(){
- return this.office;
- }
- public void setSalary(double salary){
- this.salary = salary;
- }
- public double getSalary(){
- return this.salary;
- }
- public void setHire(Date hire){
- this.hire = hire;
- }
- public Date getHire(){
- return this.hire;
- }
- public String toString(){
- return "Office " + super.getName();
- }
- }
- public class Faculty extends Employee {
- private String officeHours;
- private int rank;
- public Faculty(String name, String address, int phone, String email) {
- super(name, address, phone, email);
- }
- public String toString(){
- return "Office " + super.getOffice();
- }
- }
- public class Staff extends Employee {
- private String title;
- public Staff(String name, String address, int phone, String email) {
- super(name, address, phone, email);
- }
- public Staff(String title){
- this.title = title;
- }
- public void setTitle(String title){
- this.title = title;
- }
- public String getTitle(){
- return this.title;
- }
- public String toString(){
- return "Title :" + super.getName();
- }
- }
- Student(String name, String addr, String phone, String email) {
- ....
- }
- public String toString() {
- return this.name + "n" + this.addr + "n" + this.phone + "n" + this.email;
- }
- public Student(String name, String address, int phone, String email, String classStatus)
Add Comment
Please, Sign In to add comment