Question

JAVA please: This lab has four parts: 1. Write a Person class. 2. Write a Student...

JAVA please:

This lab has four parts:

1. Write a Person class. 2. Write a Student and Employee subclass to Person. 3. Write a Faculty and Staff subclass to Employee. 4. Write a program that creates an object of all of the above classes.

Task 1 – The Person Class First, let us make a simple class titled Person. A person should include: 1. The class variables/attributes/properties: a. Name, b. Address, c. Phone number, d. And email address. 2. An overloaded constructor that allows us to pass in all of the above variables. 3. A ToString method that returns all of the class variables AND the name of the class (which should be Person).

Task 2 – The Student and Employee Subclasses Now let us begin to use inheritance. Both the Student and Employee classes will inherit from the Person class. A Student should include: 1. One additional class variable, class status (freshman, sophomore, junior, or senior). Define the status as a constant. a. NOTE: The Student class will inherit and keep all the class variables from Person, so we are adding (without any additional code) one class variable to store their class status. 2. An overwritten constructor that takes in one additional parameter which will be used to set the class status. 3. An overwritten ToString method that will print out the class status along with the other variables AND class name (this time it should be Student). An Employee should include: 1. Additional class variables/attributes/properties: a. An office (building name/letter and number, e.g. Atrium 352 or J 352), b. Salary, c. The year, d. The month, e. And the day the Employee was hired. 2. An overwritten constructor that takes five (5) additional variables to set the Employee’s variables. 3. An overwritten ToString method that will print out the five (5) additional variables along with the previous variables AND class name (this time it should be Employee).

Task 3 – The Faculty and Staff Subclasses We will create two more classes this time they will both inherit from Employee. A Faculty member should include: 1. Additional attributes: a. Office hours in a week (e.g. 5), b. And a rank (e.g. Senior, Limited Term, etc.). 2. An overwritten constructor that takes two (2) additional variables to set the Faculty’s variables. 3. An overwritten ToString method that will print out the two (2) additional variables along with the previous variables AND class name (this time it should be Faculty). A Staff member should include: 1. One additional property that represents their title. 2. An overwritten constructor that takes in one additional parameter which will be used to set the title. 3. An overwritten ToString method that will print out the class status along with the other variables AND class name (this time it should be Staff).

Task 4 – The Driver (Main Program) Let us now use our classes by creating objects. Create one (1) of each of the above classes (1 Person, 1 Student, 1 Employee, 1 Faculty, and 1 Staff object) using user input. Finally, print out the data stored in each object using their ToString methods (DO NOT explicitly call the ToString method when doing so). Below is some possible sample output (note: ∃ simply means, “there exists”):

∃ Some Sample Output:

Person: Rey Skywalker Address: 4123 Moisture Farm, Outer Rim, Tatooine Phone Number: 444-444-4444 Email Address: ReyOfHope@students.kennesaw.edu

Student: Ben Solo Address: 78 Jedi Temple, Outer Rim Phone Number: 444-444-5673 Email Address: BSolo@students.kennesaw.edu Class Status: Freshman

Employee: Han Solo Address: Captain’s Quarters, Millennium Falcon Phone Number: 456-123-7892 Email Address: HSolo@students.kennesaw.edu Office: Cockpit of Millennium Falcon Pilot’s Chair Salary: 10000000 Date Hired: Year: 1975 | Month: 12 | Day: 5

Faculty: Luke Skywalker Address: 789 Hermit’s Retreat, Ahch-To Phone Number: 456-123-7891 Email Address: LSkywalk@students.kennesaw.edu Office: Penthouse room in Temple Salary: 5000000 Date Hired: Year: 1975 | Month: 12 | Day: 5 Office hours: 5 hours

Rank: Senior Staff: Leia Organa-Solo Address: 789 Resistance base, Outer Rim, D’Qar Phone Number: 456-123-7890 Email Address: LOrgana@students.kennesaw.edu Office: Resistance Camp Salary: 5500000 Date Hired: Year: 1975 | Month: 12 | Day: 5 Title: General

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

TASK 1

class Person {
   private String name;
   private String address;
   private String phoneno;
   private String email;

public Person() {

   }
   public Person(String name, String address, String phoneno, String email) {
       super();
       this.name = name;
       this.address = address;
       this.phoneno = phoneno;
       this.email = email;
   }

   @Override
   public String toString() {
       return "Person :" + name + ", Address:" + address + ", Phone Number:" + phoneno + ", Email Address:" + email;
   }
  
}

TASK 2

class Student extends Person {
   private final String status;

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

   @Override
   public String toString() {
       return "Student :" + name + ", Address:" + address + ", Phone Number:" + phoneno + ", Email Address:" + email
               + ",Class Status:" + status;
   }

}

class Employee extends Person {
   protected String office;
   protected int salary;
   protected int year;
   protected int month;
   protected int day;

public Employee() {
      
   }

   public Employee(String name, String address, String phoneno, String email, String office, int salary, int year,
           int month, int day) {
       super(name, address, phoneno, email);
       this.office = office;
       this.salary = salary;
       this.year = year;
       this.month = month;
       this.day = day;
   }

   @Override
   public String toString() {
       return "Employee :" + name + ", Address:" + address + ", Phone Number:" + phoneno + ", Email Address:" + email
               + ", Office:" + office + ", Salary:" + salary + ", Date Hired: Year:" + year + "| Month:" + month
               + "| Day:" + day;
   }

}

TASK 3

class Faculty extends Employee {
   private int officeHour;
   private String rank;

   public Faculty(String name, String address, int phoneno, String email, String office, int salary, int year,
           int month, int day, int officeHour, String rank) {
       super(name, address, phoneno, email, office, salary, year, month, day);
       this.officeHour = officeHour;
       this.rank = rank;
   }

   @Override
   public String toString() {
       return "Faculty:" + name + ", Address:" + address + ", Phone Number:" + phoneno + ", Email Address:" + email
               + ", Office:" + office + ", Salary:" + salary + ", Date Hired: Year:" + year + "| Month:" + month
               + "| Day:" + day + " Office Hour:" + officeHour + " hours Rank :" + rank;
   }
}

class Staff extends Employee {
   protected String title;

   public Staff(String name, String address, int phoneno, String email, String office, int salary, int year, int month,
           int day, String title) {
       super(name, address, phoneno, email, office, salary, year, month, day);
       this.title = title;
   }

   @Override
   public String toString() {
       return "Staff:" + name + ", Address:" + address + ", Phone Number:" + phoneno + ", Email Address:" + email
               + ", Office:" + office + ", Salary:" + salary + ", Date Hired: Year:" + year + "| Month:" + month
               + "| Day:" + day + " Title:" + title;
   }
}

TASK 4

public class UseOfConcepts {

   public static void main(String[] args) {
       Person p = new Person("Rey Skywalker", "4123 Moisture Farm, Outer Rim, Tatooine", "444-444-4444",
               "ReyOfHope@students.kennesaw.edu");
       Student s = new Student("Ben Solo"," 78 Jedi Temple, Outer Rim ","444-444-5673","BSolo@students.kennesaw.edu","Freshman");
       Employee e = new Employee("Han Solo","Captain’s Quarters, Millennium Falcon ","456-123-7892 ","HSolo@students.kennesaw.edu","Cockpit of Millennium Falcon Pilot’s Chair" , 10000000 ,1975 ,12 , 5);
       Faculty f = new Faculty("Luke Skywalker","789 Hermit’s Retreat, Ahch-To","456-123-7891","LSkywalk@students.kennesaw.edu","Penthouse room in Temple",5000000,1975,12, 5, 5,"Senior");
       Staff st = new Staff("Leia Organa-Solo","789 Resistance base, Outer Rim, D’Qar","456-123-7890", "LOrgana@students.kennesaw.edu","Resistance Camp", 5500000 ,1975,12,5,"General");

       System.out.println(p + " \n" + s + " \n" + e + " \n" + f + " \n" + st);
   }

}

Add a comment
Know the answer?
Add Answer to:
JAVA please: This lab has four parts: 1. Write a Person class. 2. Write a Student...
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...

  • 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...

  • 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...

  • 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....

  • 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....

  • 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...

  • Lab Exercise 05.1 Interest Rate PLEASE USE JAVA Compound interest is the way that you can...

    Lab Exercise 05.1 Interest Rate PLEASE USE JAVA Compound interest is the way that you can turn a little bit of money into a lot of money, if you have enough time. We have seen this calculation in a previous lab. This exercise will rewrite the program but will define a class named interestRate which will contain several separate methods. These methods will be incorporated into the class definition so that they can be tested by a main test program...

  • 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()...

  • 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...

  • 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...

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