Write a Java program to meet the following requirements Desi

Write a Java program to meet the following requirements: Design and declaration. All classes\' data fields should be private. (20percentage) Design an abstract class named Person and its two subclasses named Student and Employee Person has as abstract method printlnfo(). Employee is an abstract class. Make Faculty subclasses of Employee, and Employee has a salary, default 0. Person has data fields: name. Default: name is \"unknow n \', Student has a data field: age. default 0; email address, default: \"none\". Faculty has a data field: dept, default is \"none\". Add an interface interface living with a method eat() interface living {void eat(String food);} Add an interface interface working with a method teach() interface working {void teach(String course);} Implementation: (20percentage) Implement necessary constructor, accessor and mutator methods for all classes. Employee class has two interfaces: living, and workingabstract class Employee extends Person implements living, working Student class has an interface: living class Student extends Person implements living Implement a printlnfo method in necessary classes to display the class/object name and name/values of all data fields in the class. Write a test program to create two Students and two Faculties, assign (NOT read from console) tl following information, and invokes their printlnfo methods, xxxx is your Kean ID. (10percentage) A Student object name: unknown, age: -1, email: none, eat nothing. A Student object name: \"xxxx_s2\". age: 23, email: xxxxx, eat cakes. A Faculty object name: \"xxxx fl\", dept: none, salary: -1, eat oranges, teach CPS2231 A Faculty object name: \"xxxx_f2\", dept: \"CS\". salary: 10000, eat apples, teach CPS374 Your program output should look like below: (10percentage) Student name: xxxx_sl, age: -1, email: abc@gmail.com, eat cookies Student name: xxxx_s2, age: 23, email: xyz@gmail.com, eat cakes Faculty name: xxxx_fl, dept: none, salary: -1, eat oranges, teach CPS2231 Faculty name: xxxx_f2, dept: CS, salary: 10000, eat apples, teach CPS3740 Program4 is developed by chuang. This project should be coded in ONE java file.

Solution

abstract class Person {

   String name = \"unknown\";

   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }

   abstract void printInfo();
}

abstract class Employee extends Person implements living, working {
   int salary = 0;

   public int getSalary() {
       return salary;
   }

   public void setSalary(int salary) {
       this.salary = salary;
   }

}

class Faculty extends Employee {
   private String dept = \"none\", eat = \"\", course = \"\";

   public Faculty(String dept) {
       super();
       this.dept = dept;
   }

   public String getDept() {
       return dept;
   }

   public void setDept(String dept) {
       this.dept = dept;
   }

   @Override
   void printInfo() {
       System.out.println(\"Faculty [dept=\" + dept + \", eat=\" + eat + \", course=\" + course + \", salary=\" + salary
               + \", name=\" + name + \"]\");

   }

   @Override
   public void eat(String food) {
       this.eat = food;
   }

   @Override
   public void teach(String course) {
       this.course = course;

   }

}

public class Student extends Person implements living {
   private int age = 0;
   private String email_address = \"none\";
   private String food = \"\";

   public Student(int age, String email_address) {
       super();
       this.age = age;
       this.email_address = email_address;
   }

   public int getAge() {
       return age;
   }

   public void setAge(int age) {
       this.age = age;
   }

   public String getEmail_address() {
       return email_address;
   }

   public void setEmail_address(String email_address) {
       this.email_address = email_address;
   }

   @Override
   void printInfo() {
       System.out.println(
               \"Student [age=\" + age + \", email_address=\" + email_address + \", eat=\" + food + \", name=\" + name + \"]\");

   }

   @Override
   public void eat(String food) {
       this.food = food;

   }

}

interface living {
   void eat(String food);
}

interface working {
   void teach(String course);
}

 Write a Java program to meet the following requirements: Design and declaration. All classes\' data fields should be private. (20percentage) Design an abstract
 Write a Java program to meet the following requirements: Design and declaration. All classes\' data fields should be private. (20percentage) Design an abstract
 Write a Java program to meet the following requirements: Design and declaration. All classes\' data fields should be private. (20percentage) Design an abstract

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site