Examples
class, and include examples of data for each class
in your hierarchy. Tournaments should be created using the same type of sport
for all matches (i.e., a tournament of soccer matches, or a tournament of baseball matches). Your program should have a
Main
method as
described on the syllabus. Make sure that your program compiles and runs at this point before you try doing the remaining problems.
Write a method isValid()
on scores that determines whether the score is valid for its corresponding sport. In particular:
Your code should require every score (even those for other sports that we might
add later) to have an isValid
method. Make sure your code satisfies this requirement.
allScoresValid()
on tournaments that determines whether every match in the tournament has a valid score.
matchesPlayedBy()
on tournaments that consumes a contestant name and produces the number of matches in the tournament in which the named contestant played.
winnerAlwaysAdvanced
on tournaments that produces a boolean indicating whether each contestant in a match was the winner of one of the feeder matches (for initial matches, this method should produce true).
Homework that does not compile will earn a grade of 0. Homework that does not run will earn no credit for Examples and Test Cases. It is not unreasonable to ask that the work you turn in compiles without errors. If you develop your program incrementally, and thoroughly test each method before you go on to the next, you will be able to take care of errors as they occur. It is in your best interest to make one last check that your homework compiles just before you submit it. You will be graded on
this.data.score.isValid()
,
you should delegate the work to the class (MatchData
, in this example) that defines score
as a field:
this.data.isScoreValid()
Delegating in this manner reduces the impact on the program as a whole when future modifications are made. (We'll talk more about this as we go along. Here's a short paper that describes the so-called "Law of Demeter" nicely.)
Using web-based turnin, submit .java files containing the final versions of all classes, interfaces, and examples developed for this assignment. Do not submit the .class files. You may submit either a single .java file containing all classes and interfaces, or, if you organized your homework as a project, submit a .zip file containing the .java files for each class/interface.
Failure to follow these instructions for submission will result in deductions on your homework score.