Question
Create a new JUnit test suite called FootyScoreTests that thoroughly tests the provided class FootyScore. Use the Coverage tool in Eclipse to check how much
Create a new JUnit test suite called FootyScoreTests that thoroughly tests the provided class FootyScore.
Use the Coverage tool in Eclipse to check how much of FootyScore your test suite covers. Remember to consider potential bugs associated with boundary conditions.
The AMS uses a different marking algorithm for this exercise. Your test suite will be run against six versions of FootyScore, each with a separate issue that your tests need to detect. For each issue you detect, you are awarded one mark, up to a maximum of six. If the transcript indicates that a test has failed for a particular broken implementation, then that means your test suite has correctly identified the problem. So in this exercise, a failure is good!
You also have more attempts for this exercise than others, as it may involve some trial and error to get all marks.
Upload and submit your 1 class:
FootyScoreTests FOOTY SCORE JAVA CODE (FootyScore.java) -
package junit.FootyScore;
/**
* An Australian Rules football score consists of a number of
* points, accumulated by kicking goals and behinds.
*
*/
public class FootyScore {
/* Initially there is no score */
private int goals = 0;
private int behinds = 0;
/**
* Returns the total number of points, based on the number
* of goals and behinds kicked, and the number of points
* earned for each.
*
* @return the total number of points earned
*/
public int getPoints() {
final int pointsPerGoal = 6;
final int pointsPerBehind = 1;
return (goals * pointsPerGoal) + (behinds * pointsPerBehind);
}
/**
* Increments the number of goals kicked.
*/
public void kickGoal() {
goals += 1;
}
/**
* Increments the number of points kicked.
*/
public void kickBehind() {
behinds += 1;
}
/**
* Returns a string representing the way an AFL score would be
* expressed by a typical footy commentator, as the number of
* goals kicked, behinds kicked, and points earned.
*
* @return a "speakable" football score
*/
public String sayScore() {
return Integer.toString(goals) + ", " +
Integer.toString(behinds) + ", " +
getPoints();
}
/**
* Returns whether or not this team's score exceeds the given team's
* score.
*
* @param otherTeam the opposing footy team
* @return true iff this team is winning
*/
public boolean inFrontOf(FootyScore otherTeam) {
return (getPoints() > otherTeam.getPoints());
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started