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 competition structures, and (b) eliminate the need for
the Dive and DiversList classes.
PeopleScorer
Application
(in the app package)
TeamScorer Application
(in the app package)
Score interface
AbstractScore class
LeafScore class
CompositeScore 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).
PeopleScorer or TeamScorer
classes. Your tests must be in a package
named 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.Score class from the previous version.Score class (using the tool in
Eclipse), renaming it to LeafScore.Score interface.AbstractScore class.LeafScore class so that it now
specializes the AbstractScore class.Score class and renamed
it LeafScore, Eclipse made the change everywhere.
In some cases (e.g., in List objects),
you should change it back to Score (e.g.,
from List<LeafScore> to
List<Score>).
LeafScore class
(using the tests that you originally wrote for the Score
class and debug it if necessary.scoring package.
CompositeScore class.CompositeScore class.DivFileReader class from the previous
version.DivFileReader so that it uses
CompositeScore objects in place
of Dive and DiversList objects
(e.g., both readDive() and readDiversList
must now return a CompositeScore object).
DivFileReader.PeopleScorer application with
the .div files from the previous assignment.
The correct outputs for these files are:
(ST_Complete_01.div, 63.4), (ST_Complete_02.div, 46.1),
(ST_Missing-Score_01.div, 53.9),
(three-dives_five-judges_drop-both.div, 131.1), and
(four-dives_six-judges_drop-neither.div, 358.1). Of course,
you should be able to calculate the correct answers for
these files by hand, and you will need to be able to do so
if you have to debug your code. When
running PeopleScorer 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:
DifficultyTable1mS class but not including
the PeopleScorer or TeamScorer
classes).testing).You may submit your code up to 15 times with no penalty. After the 15th submission, your grade will be reduced by 5 points for each submission.
As mentioned above, points will be deducted for excessive submissions. As always, points will be deducted for code that is unclear, inelegant, and/or poorly documented.
Score is now an interface, not a class. Why?
Score class
has been moved into the AbstractScore class and
some of it has been moved into the LeafScore class.
Why?
CompositeScore class uses
a Rule and/or ScoringSystem to
calculate the numerical grade for the collection.
What design pattern is being used in this regard (i.e., in
the calculation of the numerical grade)? What are the
benefits? (Hint: The answer is not the composite
pattern. The composite pattern describes the relationship
between the Score
interface, LeafScore class,
and CompositeScore 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?
Copyright 2025