Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design a set of classes for a college application that will store a limited number of students and faculties. Classes you will need to design

Design a set of classes for a college application that will store a limited number of students and faculties. Classes you will need to design for this application include the following:

Person class: this acts as a superclass for both Student and Faculty classes. I will provide you the Person.java class.

Student class: Student is a subclass of Person. In addition to the data fields available in the Person, a Student should contain the following data fields:

Double data field named gpa (e.g., 4.0).

String data field name major (e.g., Computer Science).

Student class should override the Person method toString() to display the gpa and major.

Faculty class: Faculty is a subclass of Person. In addition to the data fields available in the Person, a Faculty should contain the following data fields:

Double data field named salary.

String data field named department.

Boolean data field isFullTime (true means the faculty is working full time).

Faculty class should override the Person method toString() to display the gpa and major.

Write an application named CollegeManager.java that declares an array of three Student and three Faculty. Prompt the user to specify what type of person he/she wants to enter:

F or Faculty: for faculty and make sure to accept upper or lower case.

S or Student: for student and make sure to accept upper or lower case.

Q or Quit: to quit and make sure to accept upper or lower case.

If the user attempts to enter data for more than three Student or Faculty display an error message as follows:

ERROR: Reached maximum allowed number of Faculty: 3

When the user quits, display a report on the screen listing all entered Faculty followed by a list of all entered Students.

Already includes the following:

import java.text.ParseException;

import javax.swing.text.MaskFormatter;

public class Person {

private String firstName;

private String lastName;

private String address;

private String phoneNumber;

public Person() {

this.firstName = "John";

this.lastName = "Smith";

this.address = "1211 south cr, mpls, MN";

this.phoneNumber = "6121111111";

}

public Person(String fname, String lname, String address, String phNumber) {

this.firstName = fname;

this.lastName = lname;

this.address = address;

this.phoneNumber = phNumber;

}

public String getFirstName() {

return firstName;

}

public void setFirstName(String firstName) {

this.firstName = firstName;

}

public String getLastName() {

return lastName;

}

public void setLastName(String lastName) {

this.lastName = lastName;

}

public String getAddress() {

return address;

}

public void setAddress(String address) {

this.address = address;

}

public String getPhoneNumber() {

return phoneNumber;

}

public void setPhoneNumber(String phoneNumber) {

this.phoneNumber = phoneNumber;

}

private void phoneFormatter() {

String phoneMask = "(###)-###-####";

MaskFormatter maskFormatter = null;

try {

maskFormatter = new MaskFormatter(phoneMask);

maskFormatter.setValueContainsLiteralCharacters(false);

phoneNumber = maskFormatter.valueToString(phoneNumber);

} catch (ParseException e) {

e.printStackTrace();

}

}

@Override

public String toString() {

phoneFormatter();

String personInfo = "\tFirst Name: " + firstName + " \tLastName: "

+ lastName + " \tAddress: " + address + " \tPhone: "

+ phoneNumber + " ";

return personInfo;

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago