Due : Code is due Wednesday September 16th at 11:00 AM (YES, that is correct)
Printouts are due at the start of class
Introduction
Let's see how well you learned how to write basic code in Java. In this assignment I will ask you to write three classes that together could be used as part of a student/course management system at a university. Notice that the creation of the third class will depend on having created the first two. Thus, I suggest that you create and test these in the order proposed below.
Class One - Student
Each student at the university is stored as an instance of the Student class. Each instance knows the student's name, idNumber, total credits earned and GPA.
Individual instances respond to the following methods
getName() - returns the String representing the student's full name
changeName() - takes a String as a parameter representing the student's full name (allows for name changes)
getID() - returns the String representing the student's id number (yes, the String)
addCredits() - takes in an int representing how many credits the student has earned. Used at the end of the semester to add credit hours
getCredits() - returns an int representing the number of credit points this student has accumulated
getGPA() - returns a double representing the student's current GPA
setGPA() - takes a double as a parameter and sets the GPA to this value
getStatus() - returns a String indicating whether the student is a freshman, sophomore, junior, or senior given UNI's definition of those terms.
getLoginName() - returns the student's computer lab id name which consists of the first four characters of their last name concatenated with the first 3 digits of their student ID number.
toString() - returns a string with basic object information as we did with WesternTown.
printInfo() - prints the name and ID number of the student in the format "Ben Schafer (123456)" (without the quotes)
Additionally, Student has a single constructor that requires the client code provide the student's full name and ID numbers (as Strings) at construction time. By default, students begin with 0 credit hours and a GPA of 0.0
For example,
Student student1 = new Student("Ben Schafer","123456");
Class Two - Faculty
Each faculty member at the university is stored as an instance of the Faculty class. Each instance of faculty knows the faculty member's name, his faculty ID number, his office number, the number of courses he teaches, and his annual salary.
Individual instances respond to the following methods
getName() - returns the String representing the faculty member's full name
changeName() - takes a String as a parameter representing the faculty member's full name (allows for name changes)
getID() - returns the String representing the faculty member's id number
getOffice() - returns the String representing the faculty member's office address
setOffice() - takes a String as a parameter ya-da ya-da
setCoursesTaught() - takes in an int representing how many courses the faculty member teaches
getCoursesTaught() - returns an int representing the number of courses taught
getSalary() - returns a double representing the faculty member's current salary
setSalary() - takes a double as a parameter and set's he faculty member's salary (used at hiring)
giveRaise() - takes a double as a parameter and raises the faculty member's salary by that amount
getLoginName() - returns the faculty member's computer lab id name which consists of the first four characters of their name (bonus if you can make it of their last name) concatenated with the first 3 digits of their student ID number.
toString() - returns a string with basic object information as we did with WesternTown.
Additionally, Faculty has a single constructor that requires the client code provide the member's full name and ID numbers (as Strings) as well as their initial salary. By default, faculty begin teaching 2 courses a semester and their office is undefined at hiring time.
For example,
Faculty faculty1 = new Faculty("Dr. Ben Schafer","654321",123456.78);
Class Three - Course
Each class taught at the University is stored as an instance of the Course class. Each instance of course knows the course number, the course name, the course room number, the maximum number of students allowed to enroll, the Faculty member who is teaching the course, and a collection of all Students currently enrolled in the course.
Individual instances respond to the following methods
getName() - returns the String representing the course name
getNumber() - returns the String representing the course number
getLocation() - returns the String representing the room number
setLocation() - takes a String which becomes the course room number
getMaxSize() - returns an int representing the maximum number of students allowed in the course
getCurrentSize() - returns an int representing the number of students currently enrolled in the course
enrollStudent() - takes an instance of the Student class and adds them to the class membership list assuming there is still room
assignFaculty() - takes an instance of the Faculty class and assigns that faculty member to be the course instructor
listStudents() - prints out a list of all the students/ids of those currently enrolled in the course
printInstructor() - prints out the name of the faculty member teaching the course
toString() - returns a string with basic object information as we did with WesternTown.
Notice that not all data has setter methods. This is done on purpose.
Additionally, Course has a single constructor that requires the client code provide the course number and course name (as Strings) as well as a maximum size. By default, the location and faculty teaching the course are not initially assigned but must be done later through appropriate methods.
For example,
Course course1 = new Course("810:053","Intermediate Computing",18);
Suggestions
As you write the code for this assignment you should also write one or more classes that contain main methods that test what you are doing. Use a version of Book.java as an example to write a class that creates two Student objects, and one faculty object and then sets up a Course to be taught to the two students by the given faculty member.
There are things in this assignment that you will not immediately know how to do. When you hit those ideas you should:
Review course notes to see if we did something similar
Review the assigned reading in the textbook
Consult the Java API for things that the basic Java classes can do
Consult a basic Java tutorial to see how "that" is done in Java (whatever "that" may be)
Ask a related question in class
Submitting your assignment
Once you have everything completed and working it is time to prepare your assignment for submission. Just to be safe, you may want to review my homework collection policies.
To upload your homework, log on to the homework submission system at:
and submit the following
Print paper copies of these, staple them together in the order listed above, and bring this single, stapled, packet to class on the due date.
One good solution, and how I tested it (added here AFTER the assignment was due)
Below is a zip file containing all five of the test files I used when I graded your assignment and ONE possible set of answers for the Student, Faculty, and Course classes assigned above. These should pass all tests and demonstrate GENERALLY good programming.