You are going to create two (2) new user defined classes that will be subclasses of the User class (Student and Faculty classes), and will create a tester class with a main() method that will create instances of all of the classes to test your program.

NOTE: all of your classes, constructors, attribute (class and instance), and methods require Javadoc comments.

1. Modify your User class from the previous assignment so that it

a. has a class constant of type String named DEFAULT_EMAIL_ADDRESS that stores "john.doe@dcmail.com" this should be set up that it is accessible from anywhere

b. includes a String attribute named emailAddress (created in such a way that it is only available directly from inside the class), that will be used to store the user's email address. NOTE: as your User.java file is being updated be sure to change your Javadoc @version to 2.0 and @since is still 1.0

c. has appropriate accessor and mutator methods for the new attribute (these should be declared in such a way that they can be accessed anywhere).

d. Modify the existing constructors to accept the extra string for the emailAddress attribute.

e. Modify the toString() method so that the email address is part of the output:

User Info for: 100123456
Password: ********
Name: John Doe (john.doe@dcmail.com)
Created on: 28-Jan-2017
Last access: 28-Jan-2017
Type: s
Enabled: true

NOTE: if you pass default Dates (e.g. new Date()) as the arguments into the default constructor your output will show the current date on the screen.

2. Create a Student.java class file that:

a. class attributes named (NOTE: their access type should be public, and they should be set up so that they cannot be change/are constants)

i. DEFAULT_PROGRAM_CODE of type String that stores "UNDC"
ii. DEFAULT_ PROGRAM _DESCRIPTION of type String that stores Undeclared
iii. DEFAULT_YEAR of type int that stores 1 (default students will be first years)

b. Inherits all of the methods and attributes of the User class, but that also has the following instance attributes (declared in such a way as that they are only accessible from inside the class):

i. A String named programCode , that will store the program code for the Student object: CSTC for Computer Systems Technician; CSTY for Computer Systems Technology; CPGM for Computer Programmer; CPA for Computer Programmer Analyst etc.
ii. A String named programDescription, that will store the program description for the Student object: "Computer Systems Technician"; Computer Systems Technology; Computer Programmer; Computer Programmer Analyst etc.
iii. A int primitive named year that will hold the year of the program they are currently enrolled in 1 for first year, 2 for second year, 3 for third year.

c. For each of your new attributes create accessor/mutator methods. Make these accessible from anywhere.

d. Defines the following constructors:

i. a parameterized constructor that takes one argument each for the inherited and new Student attributes, and then sets each attribute using the different setXxx() methods (the public ones in the parent, and new methods in the derived class) NOTE: you are NOT to call the base class' constructor using the super() keyword explicitly in this program.

As part of this constructor creation, you are instructed to go into the parent User class and comment out the default constructor. You will find that this Student constructor will now be showing an error. In a multi-line comment, state what the error is, and why it is occurring. After documenting the error in a comment, uncomment the default constructor in the User class to fix the error.

ii. a default constructor should call the parameterized one defined above passing all of the default values using the this() keyword (including the one's found in the parent), you are NOT to call the super() constructor explicitly.

this(DEFAULT_ID, DEFAULT_PASSWORD, DEFAULT_FIRST_NAME,
DEFAULT_LAST_NAME, DEFAULT_EMAIL_ADDRESS,
new Date(), new Date(), DEFAULT_TYPE,
DEFAULT_ENABLED_STATUS, DEFAULT_PROGRAM_CODE,
DEFAULT_PROGRAM_DESCRIPTION, DEFAULT_YEAR);

iii. an overloaded parameterized constructor so that this one takes a String for the student's id (instead of a long). This constructor should call the other parameterized constructor using the this() keyword, passing all of the arguments including the String id parsed as a long.

e. Override the base class' toString() method so that the Students info is displayed as below. For this method have all attributes retrieved using the getXxx() methods. You are not to call the parents toString() method (as it is totally new output):

Example 1:

Student Info for:
John Doe (100123456)
Currently in 1st year of "Undeclared" (UNDC)
Enrolled: 23-Jan-2017

Example 2:

Student Info for:
YOUR_FIRST_NAME YOUR_LAST_NAME (100543210)
Currently in 2nd year of "Computer Programmer Analyst" (CPA)
Enrolled: 3-Sep-2016

NOTE: the suffix changes for 1 st , 2 nd and 3 rd years (a student in their 4 th year should have a "th" suffix)

3. You will create a Faculty.java class file that will contain the following:

a. class attributes named (NOTE: their access type should be public, and they should be set up so that they cannot be change/are constants)

i. DEFAULT_SCHOOL_CODE of type String that stores "SET"
ii. DEFAULT_SCHOOL _DESCRIPTION of type String that stores School of Engineering & Technology
iii. DEFAULT_OFFICE of type String that stores H-140
iv. DEFAULT_PHONE_EXTENSION of type int that stores 1234

b. Inherits all of the methods and attributes of the User class, but that also has the following instance attributes (declared in such a way that they can only be accessed from inside the class):

i. a String named schoolCode that will store a code for the school the faculty is associated with. E.g. BITM for School of Business, IT & Management
ii. a String named schoolDescription that will store a code for the school the faculty is associated with. E.g. "School of Business, IT & Management"
iii. a String named office that will store the faculty member's office location. E.g. BITM for School of Business, IT & Management
iv. a primitive int named extension that will store the faculty members phone extension

c. For each of your new attributes create accessor/mutator methods. Make these public accessible.

d. Defines the following constructors:

i. a parameterized constructor that takes one argument each for the inherited and new attributes, then calls the User parent's parameterized constructor using the super(), passing the user arguments provided, and then sets the extra Faculty related attributes using the appropriate setXxx()methods
ii. a default constructor should call the parents default constructor (using the super() call) and set the extra attributes using the appropriate setXxx()methods
iii. an overloaded parameterized constructor so that this one takes a String for the students id (instead of a long). This constructor should call the other parameterized constructor using the this() keyword, passing all of the arguments including the String id parsed as a primitive long.

e. Override the base class' toString() method so that the Facultys info is displayed as below. NOTE; for this method the first part of the output is almost identical to the Users toString() output, you are therefore required to call the parents method explicitly (placing the returned String into a local variable), replace the word "User" with the word Faculty, and then add the faculty specific info to the end of the output using the getXxx() methods:

Faculty Info for: 100123456
Password: ********
Name: John Doe (john.doe@dcmail.com)
Created on: 28-Jan-2016
Last access: 28-Jan-2016
Type: s
Enabled: true
School of Science & Engineering Technology (SET)
Office: H-140
x1234

NOTE: to replace part of a string with something different, Java provides a replaceAll() method as part of the String class. To replace the word "User" with the word Faculty the call would be:

output = output.replaceAll("User", "Faculty");

4. Create a Java class named Lab3Tester.java, that has a main method that performs that creates output that is similar to that provided below (the one object should reflect your personal info).

******************** Lab 3 Output ********************

Instantiating the default user, and then call the displayToConsole() method
(to demo the modified toString() format)

User Info for: 100123456
Password: ********
Name: John Doe (john.doe@dcmail.com)
Created on: 1-Feb-2016
Last access: 1-Feb-2016
Type: s
Enabled: true

Instantiating the default student, and then call the displayToConsole() method

Student Info for:
John Doe (100123456)
Currently in 1st year of "Undeclared" (UNDC)
Enrolled: 1-Feb-2016

Instantiating a random student, passing:

Student student2 = new Student(100586123L,"password", "Robert",
"McReady", "bob.mcready@dcmail.ca", enrol, lastAccess, 's', true, "CPA",
"Computer Programmer Analyst", 3);

Student Info for:
Robert McReady (100586123)
Currently in 3rd year of "Computer Programmer Analyst" (CPA)
Enrolled: 3-Sep-2015

Instantiating another student, this one reflects my info, and call the
displayToConsole() method:

Student Info for:
YOUR_FIRST_NAME YOUR_LAST_NAME (100543210)
Currently in 2nd year of "Computer Programmer" (CPGM)
Enrolled: 3-Sep-2015

Instantiating the default Faculty object for one of my instructors info,
then calling displayToConsole():

Faculty Info for: 100123456
Password: ********
Name: John Doe (john.doe@dcmail.com)
Created on: 23-Jan-2016
Last access: 23-Jan-2016
Type: s
Enabled: true
School of Science & Engineering Technology (SET)
Office: H-140
x1234

Instantiating a Faculty object for one of my instructor’s info, passing (note
id passed as a String), then calling displayToConsole():

Faculty professor1 = new Faculty("100190125", "another password",
"Darren", "Puffer",
"darren.puffer@durhamcollege.ca",
start, last, 'f', true, "BITM", "School of
Business, IT & Management", "C-315", 2044);

Faculty Info for: 100190125
Password: ****************
Name: Darren Puffer (darren.puffer@durhamcollege.ca)
Created on: 14-Dec-2000
Last access: 10-Jan-2016
Type: f
Enabled: true
School of Business, IT & Management (BITM)
Office: C-315
x2044
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.