I have a assignment that I am having trouble with. I need to create a abstract class Person with subclasses Student, Employee, Staff, and Faculty. The problem I am running into involves the Staff and Faculty classes. Here is the parts of the UML diagram that we have to follow for the assignment, there are more classes but I pretty sure that I have completed those correctly.
Create the class structure represented in the UML diagrams below. When finished, zip all necessary source (.java) files into a single archive named with your last name and submit it along with one printed copy of each file.
For all constructors, parameters are in order of declaration (ie. name, address, phone, email, …). The class Date is provided as discussed in class.
Faculty
- officeHours : String
- rank : Rank
+ Faculty()
+ Faculty(String,String,String,String,String,int,int ,int,int,String,Rank);
+ getOfficeHours() : String
+ getRank() : Rank
+ setOfficeHours(String) : void
+ setRank(Rank) : void
+ toString() : String
≪enumeration≫
Rank
- Adjunct
- Instructor
- AssocProf
- AsstProf
- Professor
My code for the class Faculty:
class Faculty extends Employee{
enum Rank{Adjunct, Instructor, AssocProf, AsstProf, Professor};
private String officeHours;
private Rank rank;
public Faculty(){
officeHours = "";
}
public Faculty(String n, String a, String p, String e, String o, int s, int m, int d, int y, String h, Rank r){
super(n,a,p,e,o,s,m,d,y);
officeHours = h;
rank = r;
}
public String getOfficeHours(){
return officeHours;
}
public Rank getRank(){
return rank;
}
public void setOfficeHours(String h){
officeHours = h;
}
public void setRank(Rank r){
rank = r;
}
public String toString(){
return super.toString() + " Office Hours: " + officeHours + " Rank: " + rank;
}
}
Staff
- title : Title
+ Staff()
+ Staff(String,String,String,String,String,int,int,i nt,int,Title);
+ getTitle() : Title
+ setTitle(Title) : void
+ toString() : String
≪enumeration≫
Title
- Clerical
- Maintenance
- Supervisor
- Administrator
My code for the class Staff:
class Staff extends Employee{
enum Title {Clerical, Maintenance, Supervisor, Administrator};
private Title title;
public Staff(){
}
public Staff(String n, String a, String p, String e, String o, int s, int m, int d, int y, Title t){
super(n,a,p,e,o,s,m,d,y);
title = t;
}
public Title getTitle(){
return title;
}
public void setTitle(Title t){
title = t;
}
public String toString(){
return super.toString() + " Employee Title: " + title;
}
}
The problem I am running into involves the enumeration for Title and Rank. I'm pretty sure that I have used enumeration right but when I try an test it in the main program I get 4 errors (Cannot Find Symbol). The statements that are causing the errors are listed below.
error: cannot find symbol
Staff s1 = new Staff("John Doe", "5 Main St.", "123-450-6789","jd@abc.edu", "", 29000, 2, 5, 1983, Title.Clerical);
^
symbol: variable Title
location: class TestPerson
error: cannot find symbol
Faculty f1 = new Faculty("John Doe", "5 Main St.", "123-450-6789","jd@abc.edu", "", 29000, 2, 5, 1983, "", "10 to 12", Rank.Professor);
^
symbol: variable Rank
location: class TestPerson
error: cannot find symbol
System.out.println(f1.getName() + " is a" + f1.getTitle() + "his office hours are:" + f1.getOfficeHours());
^
symbol: method getTitle()
location: variable f1 of type Faculty
error: cannot find symbol
f3.setTitle(Rank.Instructor);
^
symbol: variable Rank
location: class TestPerson
I'm not sure if there is a problem with the main program or if I need to change something in the Staff and Faculty classes. If anyone could help me out with this problem it would be greatly appreciated.