Hello, I have been working on an assignment for a while now and it seems as if I was able to do most of the requirements (below), however, I was unable to finish part 7a and 7b. This is why I came here to hopefully get some help since I have no idea where I'm making a mistake which stops me from actually adding an assignment when the program is run, like it should.
I have added my whole program as a zip file so that you can have a look at it yourself as me posting code here, from multiple classes wouldn't make much sense, especially because I do not know where I'm making the mistake. Assignment class was done by me, and some parts of the Model class were done by me, the rest was provided. But if you need any more detail then hopefully the requirements below will help you understand.
Requirements:
You have been provided with a base project that enables you to enter student data
and the modules that they are enrolled in. It needs to be extended in order to
handle assignments and student submissions of those assignments. The project has
two packages (view and model). You must not modify any code in the view
package. You should be adding code to the StudentModel interface and Model
class in the model package and adding new classes to achieve the requirements
below. The system will provide messages if it cannot find what it expects in your
code.
You will be expected to
1. Create an Assignment class that can be used to create assignment objects. The
class should have fields for a reference to the module associated with the
assignment, the title of the assignment, the date when the assignment is due,
the time when the assignment is due, and the percentage of the module grade
that the assignment counts for.
2. The Assignment class should have an appropriate constructor method that
enables all the fields to be set. All fields should also have getters and setter
methods for each of the fields.
3. There should be a factory method in the Assignment class that verifies the data
entered and only creates an assignment object if the supplied data is valid.
4. The class should have an equals(Object o) method that will return true if the
two assignment objects are for the same module and have the same title.
5. The class should have a toString() method that will return a String of the form
“<module code>: <assignment title> due on dd/mm/yyyy at hh:mm” where
<module code> is the module code for the associated module, <assignment
title> is the tile od the assignment, dd/mm/yyyy is the date on which the
assignment is due, and hh:mm is the time when the assignment is due.
6. You should also write a corresponding test class for the Assignment class to
verify the operation of all the methods in the Assignment class.
7. In order for the system to work, the Model class needs a number of methods
added. The view code checks whether these methods exist and reports an error
message if the required method does not exist. These methods are:
a. addAssignment: This method should create an Assignment object
using the currently selected Module object and the parameter data
passed to the method. It should return a reference to the created
Assignment object. The parameters for this method are a String title,
an integer day number, an integer month number, and integer year
number, an integer hour number, and an integer percentage. These
parameter values should be validated according to the rules below and
the object should only be created if the parameters are valid. NOTE:
The view code will use the returned reference to output a message to
say that the object was successfully created.
b. modifyAssignment: This method should modify the current
assignment object if one has been created. If there is no current
assignment object, it should do nothing. This method receives the same
parameters as the addAssignment method and it should validate the
parameter data in the same way as the addAssignment method. This
method should return a reference to the modified object.
c. getCurrentAssignment: This method should return a reference to the
current assignment. There are no parameters for this method. If there is
no current assignment, it should return null.
d. clearAssignment: This method should clear the currently selected
assignment. There are no parameters for this method and no return
value. This will have the effect of clearing the input fields on the
Assignment data entry panel. The following get… methods need to be
implemented to see this effect.
e. getAssignmentTitle: This method should return the title of the current
assignment. There are no parameters for this method. If there is no
current assignment, it should return null.
f. getAssignmentDay: This method should return the day that the current
assignment is due. There are no parameters for this method. If there is
no current assignment, it should return 0.
g. getAssignmentMonth: This method should return the month that the
current assignment is due. There are no parameters for this method. If
there is no current assignment, it should return 0.
h. getAssignmentYear: This method should return the year that the
current assignment is due. There are no parameters for this method. If
there is no current assignment, it should return 0.
i. getAssignmentHour: This method should return the hour that the
current assignment is due. There are no parameters for this method. If
there is no current assignment, it should return 0.
j. getAssignmentMinute: This method should return the minute that the
current assignment is due. There are no parameters for this method. If
there is no current assignment, it should return 0.
k. getAssignmentPercent: This method should return the percentage
assigned to the current assignment. There are no parameters for this
method. If there is no current assignment, it should return 0.
8. Write a test class to verify that the methods added to the Model class work as
expected. You may add additional methods to the model class to support these
methods and your testing.
9. The following data validation rules should be applied:
a. None of the string fields should be blank.
b. Any year fields must be a four digit number (i.e. greater than 999) and
less than or equal to 2016.
c. Any month field should be a number between 1 and 12 inclusive.
d. Any day field should be a number between 1 and 31 inclusive where
the month is January (1), March (3), May (5), July (7), August (8),
October (10), and December (12), between 1 and 30 inclusive where
the month is April (4), June (6), September (9), and November (11),
and between 1 and 28 for February (2). We are ignoring leap years for
this exercise.
e. The hour should be a number between 0 and 23 inclusive.
f. The minute should be a value between 0 and 59 inclusive.
g. The percentage should be a value between 1 and 100 inclusive. In the
next assignment, you will be expected to verify that the total of the
percentages for assignments assigned to a module do not exceed 100.
h. If the data is not valid then you should ensure that you add an error
message saying why the action was not completed. You should also
ensure that the error messages are cleared when the next action is
performed.
i. These validation rules should be verified by your test methods.
Crossed out parts I'm not worrying about for now, as I believe that they can be dealt with later on. But like I said, most parts are done and 7 is mostly what I'm worried about. So if you have any more questions then by all means ask and I'll be happy to answer.
Thanks in advance.
My program (zipped): http://www.filedropper.com/assignment6v2