import java.util.*; /** an object of class blah author date */ class Vehicle { /**I make up the class invariant, I describe speed limit*/ final int SPEED_LIMIT = 60; /**I make up the class invariant, i describe current speed*/ int currentSpeed; public void setCurrentSpeed(int[] accelerations) { currentSpeed = Arrays.stream(accelerations).sum(); } /**i describe current speed*/ public int getCurrentSpeed() { return currentSpeed; } /**i describe within speed limit*/ public boolean isWithinSpeedLimit() { return getCurrentSpeed() <= SPEED_LIMIT; } }
- import java.util.*;
- /**
- an object of class blah
- author
- date
- */
- class Vehicle {
- /**I make up the class invariant, I describe speed limit*/
- final int SPEED_LIMIT = 60;
- /**I make up the class invariant, i describe current speed*/
- int currentSpeed;
/** */- public void setCurrentSpeed(int[] accelerations) {
- currentSpeed = Arrays.stream(accelerations).sum();
- }
- /**i describe current speed*/
- public int getCurrentSpeed() {
- return currentSpeed;
- }
- /**i describe within speed limit*/
- public boolean isWithinSpeedLimit() {
- return getCurrentSpeed() <= SPEED_LIMIT;
- }
- }