Use the following code to answer the question public class SpeedTrap { private int speedLimit; /** * Creates a new SpeedTrap with the given * speed limit * * @precondition speedLimit >= 1 * @postcondition getSpeedLimit()==speedLimit */ public SpeedTrap(int speedLimit) { if (speedLimit < 1) { throw new IllegalArgumentException("invalid speed limit"); } this.speedLimit = speedLimit; } /** * Gets the speed limit * @return the speed limit */ public int getSpeedLimit() { return this.speedLimit; } /** * Checks to see if the given miles-per-hour * is considered speeding. * * @precondition mph >= 0 * @postcondition none * * @returns true if speeding; false otherwise */ public boolean isSpeeding(int mph) { if (mph < 0) { throw new IllegalArgumentException("invalid mph"); } return (mph > this.speedLimit); }} Write a JUnit test for the SpeedTrap constructor named testWhenOneUnderSpeedLimitBoundary
Use the following code to answer the question
public class SpeedTrap {
private int speedLimit;
/**
* Creates a new SpeedTrap with the given
* speed limit
*
* @precondition speedLimit >= 1
* @postcondition getSpeedLimit()==speedLimit
*/
public SpeedTrap(int speedLimit) {
if (speedLimit < 1) {
throw new IllegalArgumentException("invalid speed limit");
}
this.speedLimit = speedLimit;
}
/**
* Gets the speed limit
* @return the speed limit
*/
public int getSpeedLimit() {
return this.speedLimit;
}
/**
* Checks to see if the given miles-per-hour
* is considered speeding.
*
* @precondition mph >= 0
* @postcondition none
*
* @returns true if speeding; false otherwise
*/
public boolean isSpeeding(int mph) {
if (mph < 0) {
throw new IllegalArgumentException("invalid mph");
}
return (mph > this.speedLimit);
}}
Write a JUnit test for the SpeedTrap constructor named testWhenOneUnderSpeedLimitBoundary
Step by step
Solved in 4 steps with 1 images