Question

Concepts Tested in this Program: Class Design Constructors Objects Inheritance Program:   Design a class named Person...

Concepts Tested in this Program:

  • Class Design
  • Constructors
  • Objects
  • Inheritance

Program:  

Design a class named Person and its two subclasses, Student and Employee. Make Faculty and Staff subclasses of Employee.

A Person object has a name, address, phone number, and email address (all Strings).

A Student Object has a class status (freshman, sophomore, junior, or senior). Define the status as a final String variable.

An Employee Object has an office number, salary (both ints ), and a date hired. Use the MyDate class defined below to create an object for date hired:

public class MyDate {

   private String date;

   public MyDate(String date){

       this.date = date;

   }

    public String getDate() {

       return date;

   }

}


A Faculty object has office hours and a rank (both Strings), while a Staff object has a title (as a String).

For the Student, Faculty, and Staff classes, create toString methods that store information about the object (in the format shown in the examples below).

Test your classes in a Driver class (within the same file) that asks the user what type of object they would like to create as well as what information they would like it to have.

The program should then use the object's toString method to print information about that object.

JAVA PLEASE and with comments!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Person.java


public class Person {

   String name;
   String address;
   String phone;
   String email;
   public Person(String name, String address, String phone, String email) {
       this.name = name;
       this.address = address;
       this.phone = phone;
       this.email = email;
   }
   @Override
   public String toString() {
       return "Person [name=" + name + ", address=" + address + ", phone=" + phone + ", email=" + email + "]";
   }
  
  
}


Student.java


public class Student extends Person {
   final String status;

   public Student(String name, String address, String phone, String email, String status) {
       super(name, address, phone, email);
       this.status = status;
   }

   @Override
   public String toString() {
       return "Student [status=" + status + ", name=" + name + ", address=" + address + ", phone=" + phone + ", email="
               + email + "]";
   }
  
  
}


Employee.java


public class Employee extends Person {
   int officeno;
   int salary;
   MyDate dateHired;
   public Employee(String name, String address, String phone, String email, int officeno, int salary,
           MyDate dateHired) {
       super(name, address, phone, email);
       this.officeno = officeno;
       this.salary = salary;
       this.dateHired = dateHired;
   }
   @Override
   public String toString() {
       return "Employee [officeno=" + officeno + ", salary=" + salary + ", dateHired=" + dateHired + ", name=" + name
               + ", address=" + address + ", phone=" + phone + ", email=" + email + "]";
   }
  
  
  
}


Faculty.java


public class Faculty extends Employee {
   String officeHours;
   String rank;
   public Faculty(String name, String address, String phone, String email, int officeno, int salary, MyDate dateHired,
           String officeHours, String rank) {
       super(name, address, phone, email, officeno, salary, dateHired);
       this.officeHours = officeHours;
       this.rank = rank;
   }
   @Override
   public String toString() {
       return "Faculty [officeHours=" + officeHours + ", rank=" + rank + ", officeno=" + officeno + ", salary="
               + salary + ", dateHired=" + dateHired + ", name=" + name + ", address=" + address + ", phone=" + phone
               + ", email=" + email + "]";
   }
  
}


Staff.java


public class Staff extends Employee {

   String title;

   public Staff(String name, String address, String phone, String email, int officeno, int salary, MyDate dateHired,
           String title) {
       super(name, address, phone, email, officeno, salary, dateHired);
       this.title = title;
   }

   @Override
   public String toString() {
       return "Staff [title=" + title + ", officeno=" + officeno + ", salary=" + salary + ", dateHired=" + dateHired
               + ", name=" + name + ", address=" + address + ", phone=" + phone + ", email=" + email + "]";
   }
  
}

Add a comment
Know the answer?
Add Answer to:
Concepts Tested in this Program: Class Design Constructors Objects Inheritance Program:   Design a class named Person...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • a c++ program (The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person...

    a c++ program (The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, and date hired. Use the MyDate classto create an object for date hired. A faculty...

  • Part I: (The Myate class) Design a class named MyDate. The class contains: • The data...

    Part I: (The Myate class) Design a class named MyDate. The class contains: • The data fields year, month, and day that represent a date. Month is 0-based, i.e., 0 is for January. • A no-arg constructor that creates a MyDate object for the current date. • A constructor that constructs a MyDate object with a specified elapsed time since midnight, January 1, 1970, in milliseconds. • A constructor hat constructs a MyDate object with the specified year, month, and...

  • Java Programming Design a class named Person and its two subclasses named Student and Employee. A...

    Java Programming Design a class named Person and its two subclasses named Student and Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, date hired. Define a class named MyDate that contains the fields year, month, and day. Override the toString method in each class to display the class name and the person's name....

  • Design a class named Person and its two derived classes named Student and Employee. MakeFaculty and Staff derived classes of Employee

    In Java(The Person, Student, Employee, Faculty, and Staff classes)Design a class named Person and its two derived classes named Student and Employee. MakeFaculty and Staff derived classes of Employee. A person has a name, address, phone number, and e-mail address. A student has a class status (freshman, sophomore, junior, or senior). An employee has an office, salary, and date hired. Define a class namedMyDate that contains the fields year, month, and day. A faculty member has office hours and a rank....

  • Please answer all the questions 2. Design two programs named BaseClass and SubClass. In BaseClass, define...

    Please answer all the questions 2. Design two programs named BaseClass and SubClass. In BaseClass, define a variable xVar (type: char, value: 65), and a method myPrint to print xVar. SubClass is a subclass of BaseClass. In SubClass, define a variable yVar (type: int, value: 16) and another variable strVar (type: String, value: "java program!"). There is also a method myPrint to print the value of yVar and strVar in SubClass, as well as an additional method printAll, in which...

  • Implement an abstract class named Person and two subclasses named Student and Staff in Java. A person has a name, address, phone number and e-mail address. A student has a credit hour status (freshman...

    Implement an abstract class named Person and two subclasses named Student and Staff in Java. A person has a name, address, phone number and e-mail address. A student has a credit hour status (freshman, sophomore, junior, or senior). Define the possible status values using an enum. Staff has an office, salaray, and date-hired. Implement the above classes in Java. Provide Constructors for classes to initialize private variables. Getters and setters should only be provided if needed. Override the toString() method...

  • In this laboratory, we are going to build a base class and a collection of derived...

    In this laboratory, we are going to build a base class and a collection of derived classes. Write the code to implement the class Person. A person has a name, address,telephone number and and E-Mail address. Be sure to include accessor functions to return each of these values. Create a derived class Student which has a class status (freshman, sophomore, junior, or senior). Create a derived class Employee which has the attributes office, salary, and date hired. Now define a...

  • Please provide the code for the last part(client side program). yes i have all the class...

    Please provide the code for the last part(client side program). yes i have all the class implementations. ``` person.h #ifndef PERSON_H #define PERSON_H #include <string> using namespace std; class person { public: person(); string getname() const; string getadd() const; string getemail() const; string getphno() const; string toString() const; private: string name; string add; string email; string phno; }; ```person.cpp #include "person.h" person::person() { name = "XYZ"; add="IIT "; email="%%%%"; phno="!!!!!"; } string person::getname() const { return name; } string person::getadd()...

  • Design a class named Person with fields for holding a person's name, address, and telephone number...

    Design a class named Person with fields for holding a person's name, address, and telephone number (all as Strings). Write a constructor that initializes all of these values, and mutator and accessor methods for every field. Next, design a class named Customer, which inherits from the Person class. The Customer class should have a String field for the customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write a constructor that initializes...

  • The following is for java programming. the classes money date and array list are so I are are pre...

    The following is for java programming. the classes money date and array list are so I are are pre made to help with the coding so you can resuse them where applicable Question 3. (10 marks) Here are three incomplete Java classes that model students, staff, and faculty members at a university class Student [ private String lastName; private String firstName; private Address address; private String degreeProgram; private IDNumber studentNumber; // Constructors and methods omitted. class Staff private String lastName;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT