Read the Expectations on Homework and the Homework Tips.
LinkedList API: https://docs.oracle.com/javase/8/docs/api/java/util/LinkedList.html
Note to those with prior Java experience: One goal of 2102 is to help everyone learn when different iteration constructs (for, while, etc) are needed for a particular problem. Style grading will check whether you are using appropriate constructs. This week, we will cover the per-element style for loop, not the for loop that uses a variable to index into elements. For full points, do not use index-based for loops on this assignment. Use a per-element style loop instead.We will have covered the material for this assignment during the second week of classes.
SkiingResult
so that the times of each lap are stored in a LinkedList
instead of four separate doubles. The constructor will still take four doubles, but they will be added to a LinkedList
inside the constructor.
pointsEarned
in SkiingResult
to now total the points across all laps in the list. If the list is empty, return zero points. Be sure to use loops!
MassStartResult
to your project. Like a SkiingResult
, a MassStartResult
has a finishing position, four laps, and the number of penalties. The pointsEarned
is the total time across all four laps, and the penalties are calculated the same way as SkiingResult
. Unlike a SkiingResult
, a MassStartResult
also has a starting position which is the first parameter in the constructor. MassStartResult
should also be an IEvent.
Create abstract classes as needed to share appropriate details between SkiingResult
and MassStartResult
. You may use whatever names you wish for these classes.
Do NOT add a MassStartResult
field to your Athlete
or FinalResult
classes. We are simply creating the ability to have a new kind of event, but the athletes in this assignment will not participate in it. Larger projects often have classes that don't get used in all scenarios.
Athlete
class. Remember to also modify your constructor.
Competition
, which contains an integer indicating the (non-negative) number of ShootingRound
s to be used in this competition. It should also contain a LinkedList
of Athlete
s.
ShootingResult
class to now contain a list of ShootingRound
s (rather than a fixed four rounds). We assume the rounds are in order (the first round went first, the second went second, etc).
pointsEarned
in ShootingResult
to now total the points across all rounds in the list. If the list is empty, return zero points. Be sure to use loops!
ShootingRound
class indicating whether or not the round is standing. Remember to also modify your constructor.
bestRoundByType
in the ShootingResult
class to return the best round in the list. The method should take a boolean as a parameter to indicate if we want the best prone (false) or the best standing (true) round. If there is a tie between the top two rounds, just return one of the rounds. If there are no rounds of the specified type, return null.
Pay particular attention to creating a thorough set of tests for this method.
Competition
class called shootingDNF
(for "did not finish"), which produces a LinkedList
of the names of the Athletes in the competition whose list of ShootingRound
s is less than the number of rounds stored in the Competition
class. If there are no Athletes who meet these criteria, the method should return an empty linked list.
The names of the Athletes should occur in the same order in the returned list as they were in the list within the Competition.
Competition
class called finalScoreForAthlete
, which takes the name of an athlete and returns the final score that the athlete earned in the biathlon. You may assume that no two athletes have the same name. You may also assume that the athlete name given is in the competition (we'll talk about how to handle error cases later in the course).
Competition
class called anyImprovement
, which takes another Competition
as input and returns true if any of the athletes in "this" competition had a better final score than they had in the given competition. You may assume that both competitions have the same athletes, but the athletes may appear in different orders within the athlete lists in both competitions.
Pay particular attention to creating a thorough set of tests for this method.
finalScoreForAthlete
and anyImprovement
. In hindsight, do you see any helper methods that you should have written that could have been shared over those two problems, or are you happy with how you organized the code?
Put your answer (a couple of sentences) in a comment at the bottom of your Competition
class. You do not need to write any code or rewrite either method for this question. We're just asking you to reflect on your code and tell us what changes you might have made were you to do this pair of problems again.
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.
You are welcome to leave this file in the directory when you submit your work.
The grading rubric for Homework 2 will not be posted.
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. The name of the project in InstructAssist is Homework 2. Do not submit the .class files. Make sure all of your tests are in separate files from your code, as explained in the Expectations for Preparing Homework. 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 that your test files include ONLY calls to methods that are listed in the assignment handout. If your tests include calls to other/helper methods or references to fields, your tests will fail to compile against our solution and we won't be able to auto-grade your work.