VoteReader is a class which should really read votes from a file, but I hate
Java's I/O mechanism, so I hard-coded it. It contains three sample votes.
a) List the most important types of vote that you think need to be tested
(including those already provided)
b) Create test cases in the VoteReader class to cover those types of vote
A contract has been agreed between the authors of the classes VoteReader and
Vote. The author of VoteReader has responsibility for ensuring that it only
creates votes that could possibly have been cast. Therefore, the author of Vote
will assume that the LinkedList passed to its constructor contains objects of
type Preference, that the candidate names are all valid (see ElectionENV) and
that there are no duplicate candidate names.
a) Write informal JML for the constructor of Vote which sets out the
pre-conditions of this contract
b) Write formal JML for the same contract
Vote.validateVote() is a method which turns any possible vote into a valid
vote. If the vote is spoiled, it throws a SpoiledVoteException. Otherwise, it
creates a new list of preferences called clean_prefs. For the sake of future
developers who might want to alter the Vote class, we can set pre-conditions
and post-conditions on this method.
a) Write informal JML for the pre-conditions and post-conditions of this method
b) Write formal JML for the pre- and post-conditions, and for the exceptional
post-condition
a) What methods need to be pure?
b) What variables need to be made spec_public?
Extra marks: invariants
| Home |