They have decided that their earlier design was both too complicated
and not flexible enough. Hence, for this assignment you must
implement their new and improved design. In particular, you must use
the composite pattern to: (a) make it possible to have arbitrarily
complicated grading schemes, and (b) eliminate the need for the
History
and Cohort
classes.
app
package)
LabeledDouble
interface
AbstractLabeledDouble
class
LeafLabeledDouble
class
CompositeLabeledDouble
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.
LabeledDouble
is now an interface, not a class. Why?
LabeledDouble
class has been moved into
the AbstractLabeledDouble
class and some of it
has been moved into the LeafLabeledDouble
class. Why?
CompositeLabeledDouble
class uses
a Filter
and/or Calculator
to
calculate the numerical value for the collection.
What design pattern is being used in this regard (i.e., in
the calculation of the numerical value)? What are the
benefits? (Hint: The answer is not the composite
pattern. The composite pattern describes the relationship
between the LabeledDouble
interface, LeafLabeledDouble
class,
and CompositeLabeledDouble
class.)
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?
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 Numerics
classes from the previous version.LabeledDouble
class from the previous
version.LabeledDouble
class (using the tool in
Eclipse), renaming it to LeafLabeledDouble
.LabeledDouble
interface.AbstractLabeledDouble
class.LeafLabeledDouble
class so that it now
specializes the AbstractLabeledDouble
class.LabeledDouble
class and renamed
it LeafLabeledDouble
, Eclipse made the change everywhere.
In some cases (e.g., in List
objects),
you should change it back to LabeledDouble
(e.g.,
from List<LeafLabeledDouble>
to
List<LabeledDouble>
).
LeafLabeledDouble
class (using the tests
that you originally wrote for the LabeledDouble
class and debug it if necessary.math
package.
CompositeLabeledDouble
class.CompositeLabeledDouble
class.LetterGrade
and JMUCourseTable
classes from the previous
version.InputUtilities
class from the previous
version.InputUtilities
class so that it uses
CompositeLabeledDouble
objects in place
of History
and Cohort
objects
(e.g., both readGradeHistory()
and readCohort()
must now return
a CompositeLabeledDouble
object).
The readCohort()
method must return a CompositeLabeledDouble
object that uses a null
Filter
and a WeightedAverageCalculator
with
null
weights. It must pass the Filter
and Calculator
that it is
passed to the readGradeHistory()
method for it to use.
InputUtilities
class.TranscriptzH5
class.
When running the main class it is a good idea to include the
full path and file name in the command-line/run arguments,
otherwise, depending on where you put the files, you will
get a FileNotFoundException
. (Remember to put
the whole thing in quotes if it contains spaces.)
.zip
file that contains:
testing
).You may submit your code up to 10 times with no penalty. After the 10th submission, your grade will be reduced by 5 points for each submission. Given the work you have completed so far, you should only need one submission.
Note that you will not be given hints if your code does not conform to the style guide and/or does not pass your tests. You must now identify and correct these issues in your development environment.
As always, points will be deducted manually for code that is unclear, inelegant, and/or poorly documented.
Copyright 2024