For this and all remaining homework assignments, you should create a project where each class and interface is defined in a separate file (you did this in Lab 2). DrJava users should create a .zip file containing the java source files (under Project, choose "Create Jar File from Project", and in the next window check "java source files". Use .zip as the extension on your filename). Eclipse users can go to the JavaWorkSpace folder and create a zip file of the project.
Examples
class (no examples, no test cases). Remove
all signatures (obligations) from the ITournament
and IScores
interfaces, and
the implementations of those methods from the classes that implement
the interfaces.
IScore
.
The components of a
SwimmingScore
are the times of the two contestants.
MatchData
consisted of the names (Strings) of the two
contestants, and the score of the match. Modify MatchData
so that instead
of using a
String to represent a contestant, you use the type IContestant
,
the way we developed it in class.
Implement separate contestants for soccer, baseball, and swimming,
subject to the following constraints:
Examples
class, based on these new data definitions.
Make sure you use the signatures as given on the class handout.
winner()
on scores that consumes two contestants
(in order, i.e. the first contestant parameter had the first score, and the
second contestant parameter had the second score) and returns the name of whichever contestant won that match.
Note that the winner for Swimming
is the contestant with the
shorter time. If the score for a particular sport is a tie, return the name
of one of the contestants (it doesn't matter which name is returned).
winner()
on MatchData
, that produces the name of the
contestant that won the match (in the case of a tie, it doesn't matter which
name is returned).
hasBetterRanking()
for all ranked contestants
that consumes another ranked contestant and determines whether this contestant is ranked better than the given contestant. Lower numbers represent better ranks.
isBalanced
on tournaments that returns true if the tournament is perfectly balanced,
and false otherwise.
Examples
class.
Programs must compile in order to receive credit. Programs must run in order to receive credit for Examples and Test Cases. Code that is commented out will not be graded.
Using web-based turnin, submit .java files (as a .zip file) containing the final versions of all classes, interfaces, and examples developed for this assignment. Do not submit the .class files.