Athlete
class with one field that holds a FinalResult
object.
FinalResult
class holds a ShootingResult
object and a SkiingResult
object.
ShootingResult
class holds four separate ShootingRound
objects, one for each of four rounds (e.g., round1
, round2
, round3
, and round4
). Each ShootingRound
stores the number of targets hit (out of five). Use int
for this value. Assume that only valid numbers of targets hit will be created; you do not need to do any error checking at this point in the course.
SkiingResult
class holds the time (in seconds) at which the athlete crossed the finish line for each lap, the athlete's position in the finishing order on the final lap (1 for first, 2 for second, etc), and the number of penalties earned. Use a double for each of the four lap times and an int for the position and the number of penalties.
ShootingResult
and SkiingResult
should implement an IEvent
interface. This interface should require two methods:pointsEarned
which takes no additional inputs and returns a double
representing an athlete's score on that eventgetPenalties
which takes no additional inputs and returns a double
representing the amount of penalty time the athlete earned on that eventShootingResult
is the sum of the targets hit for each round.ShootingResult
is 60 seconds for each target missed in each round. For ShootingResult
, make the getPenalties
method call the pointsEarned
method as part of its calculation.SkiingResult
is the sum of each lap time.SkiingResult
is 5 seconds for each penalty. (A penalty is given for an illegal maneuver while skiing.)
FinalResult
class, include a method called finalScore()
that takes no inputs and returns the athlete's final score. This score will be a combination of the athlete's skiing time, shooting penalties, and skiing penalties along with a modifier based on skiing position.
Athlete
class, include a betterSkiier
method that takes another Athlete
as input and returns a boolean indicating whether the athlete has a lower skiing time (without penalties) than the given (input) Athlete
. Assume there are no ties (meaning we won't test for ties and neither should you, as the behavior in event of a tie is not specified).
Athlete
class, include a betterShooter
method that takes another Athlete
as input and returns a boolean indicating whether the athlete has a higher shooting score (without penalties) than the given (input) Athlete
.
Athlete
class, include a hasBeaten
method that takes another Athlete
as input and returns a boolean indicating whether the athlete has a higher shooting score or a lower skiing score than the given (input) Athlete
(again, without penalties). You must use calls to betterSkiier
and betterShooter
in this method.
Examples
. Your class must be called this so that the auto-grader can find it!
Note on testing Doubles: When you want to use assertEquals to compare doubles, you include a third argument which is the allowable difference between the two values for them to still be considered equal. For example:
assertEquals(5.0, 4.995, .01)returns
true
. Doubles can be imprecise due to the way they are represented within the computer, hence the need for this third argument.
Note on Writing Tests that Compare Objects: A subtlety to JUnit (that we will talk about next week) affects how you write tests that compare objects. When writing these tests, name the objects for your rounds and use the names in the assertEquals
test. The example below assumes that ShootingResult contains a hypothetical method called bestRound() that returns a ShootingRound:
public class Examples { ShootingRound longRound = new ShootingRound(...); ShootingResult goodResult = new ShootingResult(... longRound ...); ... @Test public void testLongBest() { assertEquals(longRound, goodResult.bestRound()); } }You should NOT make a new
ShootingRound
for the expected answer in the assertEquals
. Such a test would fail, even if the two rounds had the same contents (again, for reasons we will explain in detail in week 2).
Just because your program passes all of your JUnit tests does not guarantee that it will pass all of ours. However, you can minimize the risk that your methods will fail our JUnit tests by sticking with the proper naming conventions and writing as many edge cases as possible. The more testing you do, the less the likelihood of failure!
If you get a compilation error involving this file on a class or method that you defined, do not edit this file. Edit your files instead! As you are working, you may wish to comment out sections of the file that check methods you haven't written yet (that's fine). The final work you turn in should, however, compile against the entire contents of this file.
Just because your programs compiles does not mean that your program will pass all of the auto-grader tests! A program can compile but still be full of errors. The CompileCheck file is there only to make sure your naming conventions are correct, not that your classes and methods work correctly.
You are welcome to leave this file in the directory when you submit your work.
You can find the grading rubric for this assignment by clicking on this link. It will prompt you to download an Excel file. You will only be provided with a grading rubric for the first homework assignment. This is to give you an idea of our expectations for each assignment.
Here are some details on what we will look for in grading this assignment:
Programs must compile in order to receive credit. If you submit a program that doesn't compile, the grader will notify you and give you one chance to resubmit within 24 hours; a penalty (25% of the total points for the assignment) will be applied as a resubmission penalty. Code that is commented out will not be graded.
Submit (via InstructAssist) a single zip file (not tar, rar, 7zip, etc) containing all of your .java files that contain your classes, interfaces, and examples for this assignment. Do not submit the .class files. You may put all of your other classes and interfaces either into a single file or into separate ones (as you prefer). If you have separate src and test subdirectories, you may retain that structure in your zip file.
Make sure all of your tests are in separate files from your code, as explained in the Expectations for Preparing Homework.