They have decided that their earlier design was not flexible enough.
Hence, for this assignment you must implement their new and improved
design. In particular, you must use the Composite Pattern to make it
possible to have arbitrarily complicated course structures. You must
also use the Factory Method pattern to improve the creation of
grades from their String
representations.
Gradient
class for this Sprint
AbstractGrade
class
CompositeGrade
class
Grade
interface
LeafGrade
class
CourseReader
class
Note that these documents provide details where they are needed (e.g., where they have changed from the earlier designs) and omit them where they are not (e.g., where they haven't changed from the earlier designs).
testing
,
and each test class must include the word "Test" in its name.
In this case, it is particularly important that you give some thought to the order in which you make changes to the existing code, since it can be done fairly efficiently or very inefficiently. In other words, the refactoring tool in Eclipse can be very helpful if used thoughtfully or it can create an enormous amount of unnecessary work if used sloppily.
I would suggest you sequence your activities as follows. However, you should think about how this process will work for you given the way you implemented your tests.
SizeException
and Missing
classes from the previous version.Grade
class from the previous version.Grade
class, renaming it to
LeafGrade
.Grade
interface.AbstractGrade
class.LeafGrade
class so that it now
specializes the AbstractGrade
class.Grade
class and renamed
it LeafGrade
, Eclipse made the change everywhere.
In some cases (e.g., in List
objects),
you should change it back to Grade
(e.g.,
from List<LeafGrade>
to
List<Grade>
).
LeafGrade
class (using the tests
that you originally wrote for the Grade
class and debug it if necessary.grading
package of the previous version.
Grade
object it will
now need to construct a LeafGrade
object).
CompositeGrade
class.CompositeGrade
class.CourseReader
class so that it no
longer uses the Category
and Course
classes.CourseReader
class.FileNotFoundException
. (Remember to put the
whole thing in quotes if it contains spaces.).zip
file named sub5.zip
that contains:
testing
) and all of the data
files used by your JUnit tests (in the same
directory).There is no limit on the number of submissions and no penalty for excessive submissions.
As always, points will be deducted manually (i.e., outside of Gradescope) for code that is unclear, inelegant, and/or poorly documented.
Grade
is now an interface, not a class. Why?
Grade
class
has been moved into the AbstractGrade
class and
some of it has been moved into the LeafGrade
class.
Why?
CompositeGrade
class that
contains a collection of Grade
objects and uses
a Filter
and/or Strategy
to
calculate the numerical grade for the collection.if
statement can be used. For example, you
should almost never catch
a NullPointerException
you should, instead,
use an if
statement to see if the object
is null
. Why?
Copyright 2025