Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Design a class named SchoolAssociate and its two subclasses named Student and Employee. Make the classes Faculty and Staff subclasses of Employee. a. A

1. Design a class named SchoolAssociate and its two subclasses named Student and Employee. Make the classes Faculty and Staff subclasses of Employee.

a. A SchoolAssociate has a name, address, phone number, and email address. You do NOT need to verify the format of these strings except for email. Verify that the email string contains an @.

b. A student has a class status (UnderGrad_Freshman, UnderGrad_Sophomore, UnderGrad_Junior, or UnderGrad_Senior, Grad_Masters, Grad_Phd) and a major. The classStatus field should be checked to assure it is one of the 6 valid choices when passed into the constructor or the mutator method (setClassStatus()). The major field does not need to be verified.

c. An Employee has an office (room number) and salary. You do NOT have to verify the format of the office field when passed to the constructor or mutator. Assure that the salary is not a negative number.

d. A faculty member has the department the faculty belongs to and a rank (Lecturer, AssistantProf, AssociateProf, or Professor). Verify that the rank is one of the 4 values mentioned when passed into a constructor or the setRank() method.

e. A Staff member has a title. You do NOT need to verify the format of the Title string. All fields mentioned above are Strings except for salary which is a double and is specified in Korean Won. The strings for class status must match one of the six strings shown in the parenthesized list in 1.b. above. Office strings should be formatted <3digitnumber (100-799)> (e.g. A201, B419, C704). All of the members must be declared private!

2. Write appropriate constructors for each making use of the super class constructor to initialize fields belonging to the parent class. The constructor for each class should accept values for each member in that class (and its superclasses!).

3. Write accessor and mutator methods for each field. These methods should be in the appropriate class! A getName() method should be in SchoolAssociate() but one of the child classes. The getSalary() should be in Employee and getTitle() should be in the Staff class as additional examples. Override the toString method in each class to display the class name and the person's name. But for each child class add the following to the string: 1. For Student, add their class status and major

2. For Employee, add their office and the string Salary: undisclosed.

3. For Staff, add their Title

4. For Faculty, add their Department and rank

Note that Employee and SchoolAssociate should NOT print their class name since they are parent classes. However, their toString() methods are needed to provide some information (SchoolAssociate provides the persons name and Employee adds just the office and Salary strings.)

Write a test program is provided (TestSchoolAssociates.java). Look at that to assure you code your Constructor with arguments in the correct order. The test code will create various types of School Associates and print them out to show the .toString() methods work correctly.

Sample Output

The test code provided should produce the following output:

SchoolAssociate: email address invalid! Faulty: Invalid Rank!

Employee: Invalid Salary Student: Joe Cool Undergrad_Freshman CS

Faculty: John Doe Office: A304 Salary: undisclosed Department: Computer Science Rank: AssistantProf

Staff: Jane Kim Office: B401 Salary: undisclosed Title: Admin Assistant

Student: Mincheol Kang Undergrad_Freshman CS

Faculty: Terrance Stamp Office: A504 Salary: undisclosed Department: Computer Science Rank: AssistantProf

Staff: Tom Thom Office: B601 Salary: undisclosed Title: Admin Assistant

Student: Jim Bob Undergrad_Freshman CS

Faculty: Terrance Stamp Office: A504 Salary: undisclosed Department: Computer Science Rank: null

Staff: Tom Thom Office: B601 Salary: undisclosed Title: Admin Assistant

Test code

public class TestSchoolAssociate { public static void main(String[] args) { // TODO Auto-generated method stub Student std1 = new Student("Joe Cool", "115 15th St, Brooklyn, NY", "+1 212-445-5010", "jcool@brooklyu.edu", "Undergrad_Freshman", "CS"); Faculty fac1 = new Faculty("John Doe", "101 Class St, Brooklyn, NY", "+1 212-424-2345", "jdoe@brooklyu.edu", "A304", 60000000, "Computer Science", "AssistantProf"); Staff stf1 = new Staff("Jane Kim", "102 Bighorn Avenue, Brooklyn, NY", "+1 212-424-5432", "jkim@brooklyu.edu", "B401", 41000000, "Admin Assistant"); Student std2 = new Student("Mincheol Kang", "2011 18th St, Brooklyn, NY", "+1 212-445-5129", "mkang@brooklyu.edu", "Undergrad_Freshman", "CS"); Faculty fac2 = new Faculty("Terrance Stamp", "1011 Perry St, Brooklyn, NY", "+1 212-424-3131", "tstamp@brooklyu.edu", "A504", 60000000, "Computer Science", "AssistantProf"); Staff stf2 = new Staff("Tom Thom", "102 Bighorn Avenue, Brooklyn, NY", "+1 212-636-0001", "tthom@brooklyu.edu", "B601", 41000000, "Admin Assistant"); Student std3 = new Student("Jim Bob", "2011 18th St, Brooklyn, NY", "+1 212-445-5129", "jimbobbrooklyu.edu", "Undergrad_Freshman", "CS"); Faculty fac3 = new Faculty("Terrance Stamp", "1011 Perry St, Brooklyn, NY", "+1 212-424-3131", "tstamp@brooklyu.edu", "A504", 60000000, "Computer Science", "AsstProf"); Staff stf3 = new Staff("Tom Thom", "102 Bighorn Avenue, Brooklyn, NY", "+1 212-636-0001", "tthom@brooklyu.edu", "B601", -20000000, "Admin Assistant"); System.out.println(std1); System.out.println(fac1); System.out.println(stf1); System.out.println(std2); System.out.println(fac2); System.out.println(stf2); System.out.println(std3); System.out.println(fac3); System.out.println(stf3); } }

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_2

Step: 3

blur-text-image_3

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

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

Discuss the key ambient conditions and their effects on customers.

Answered: 1 week ago