1. Create a Mark.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. MINIMUM_GPA of type float that stores 0.0
ii. MAXIMUM_GPA of type float that stores 5.0
iii. GPA of type DecimalFormat that formats decimal numbers to one decimal place with a leading zero
b. has the following attributes (declared in such a way as that they are only accessible from inside the class):
i. a string named courseCode attribute that will contain the course code for the mark
ii. a string courseName that will contain the course name for the mark
iii. a primitive integer named result that will store the student's final result in the course
iv. a float named gpaWeighting that will hold the courses GPA weighting
c. has accessor/mutator methods for this class (that are accessible from everywhere)
d. has a parameterized constructor that takes arguments, one each for the attributes above (this constructor should be accessible from everywhere).
e. Has a toString() method that returns a String of the mark's info. Be sure to use the getXxx() methods to retrieve the objects attributes. The output should take the form:
WEBD2201 Web Development - Fundamentals 71 4.0
NOTE: the gpa weighting should be formatted to show one decimal place and a leading zero using the class GPA DecimalFormat object. To set a consistent width for the course name, use the String.format() method, this will allow to set a fixed width. The following will output the course name 35 characters wide (the negative sign left-aligns the output):
String.format("%-35s" , getCourseName())
2. Modify the Student.java class file from the previous assignment so that:
a. adds the following attribute (declared in such a way as that they are only accessible from inside the class):
i. An Vector named marks, this Vector should be declared that it can only contain Mark type objects
b. for the new attribute(s) create accessor/mutator method(s). Make these accessible from anywhere.
c. has two more overloaded constructors created to take the extra Vector of marks object (you need two so that you can support both long and String id arguments) . Existing constructors should be modified so that they pass an empty Vector of Mark objects to the two new constructors
d. the toString() method makes the determination that if the Student has marks (i.e. the marks attribute does not have a size of zero) it will loop through all of their marks and adds them to the Student objects output (calling the Mark objects toString() method). If the student does not have marks, the output should append "No marks on record" to the output
3. Create a Java class named Lab4Tester.java, that has a main method that performs the following:
a. Builds upon the Lab3Tester.java created in the last assignment.
b. You program should instantiate a Vector object that will store User objects named users:
Vector< User> users = new Vector< User>();
c. You are to modify the program that instead of calling displayToConsole() after instantiating the various Users/Students/Faculty objects you are to load them onto the users object created above.
d. To test the new Vector attribute of marks in the Student class, you are to create at least 5 Mark objects, load them on to a Vector of Mark objects using the add() method and then pass this Vector to your newly overloaded constructor.
e. You program should use the size of the users Vector to loop through the various objects, calling displayToConsole() each time. Java will call the appropriate toString(). This is polymorphism.
Possible Output
******************** Lab 4 Output ********************
Instantiating the default user, and then loading it on the Vector of Users
Instantiating the default student, and then loading it on the Vector of Users
Instantiating a random student before loading it onto the Vector of Users,
passing:
Student student2 = new Student(100586123L,"password", "Robert",
"McReady", "bob.mcready@dcmail.ca", enrol, lastAccess, 's', true, "CPA",
"Computer Programmer Analyst", 3);
Instantiating another student, this one reflects my info, including a Vector
of Mark objects, and then loading it on the Vector of Users.
Instantiating the default Faculty object, and then loading it on the Vector of
Users
Instantiating a Faculty object for one of my instructor's info, passing (note
id passed as a String), and then loading it on the Vector of Users:
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);
To demonstrate polymorphism, the program is now going to loop through the
Vector of Users, calling displayToConsole() on each:
User Info for: 100123456
Password: ********
Name: John Doe (john.doe@dcmail.com)
Created on: 4-Feb-2016
Last access: 4-Feb-2016
Type: s
Enabled: true
Student Info for:
John Doe (100123456)
Currently in 1st year of "Undeclared" (UNDC)
Enrolled: 4-Feb-2016
No marks on record
Student Info for:
Robert McReady (100586123)
Currently in 3rd year of "Computer Programmer Analyst" (CPA)
Enrolled: 3-Sep-2015
No marks on record
Student Info for:
YOUR_FIRST_NAME YOUR_LAST_NAME (100543210)
Currently in 2nd year of "Computer Programmer" (CPGM)
Enrolled: 3-Sep-2015
COMM3201 Communications I For IT 65 3.0
COPS1104 Computer Operating Systems 77 4.0
CSYS1122 Computer Systems-Hardware 81 4.0
DBAS1201 Intro to Databases 68 4.0
MATH1100 Mathematics for IT 73 3.0
WEBD2201 Web Development - Fundamentals 71 4.0
Faculty Info for: 100123456
Password: ********
Name: John Doe (john.doe@dcmail.com)
Created on: 4-Feb-2016
Last access: 4-Feb-2016
Type: s
Enabled: true
School of Science & Engineering Technology (SET)
Office: H-140
x1234
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