Ad

As a driver, I can see the current speed of my vehicle so that I can see if I'm within the speed limit or not.

Code
Diff
  • import java.util.*;
    
    class Vehicle {
      
      final int SPEED_LIMIT = 60;
      int currentSpeed;
      
      public void setCurrentSpeed(int[] accelerations) {
        this.currentSpeed = Arrays.stream(accelerations).sum();
      }
      
      public int getCurrentSpeed() {
        return this.currentSpeed;
      }
      
      public boolean isWithinSpeedLimit() {
        return getCurrentSpeed() <= this.SPEED_LIMIT; 
      }
      
    }
    
    • import static java.util.stream.IntStream.of;
    • import java.util.*;
    • class SpeedLimit {
    • static int sequence(int[] arr) {
    • return of(arr).sum();
    • class Vehicle {
    • final int SPEED_LIMIT = 60;
    • int currentSpeed;
    • public void setCurrentSpeed(int[] accelerations) {
    • this.currentSpeed = Arrays.stream(accelerations).sum();
    • }
    • }
    • public int getCurrentSpeed() {
    • return this.currentSpeed;
    • }
    • public boolean isWithinSpeedLimit() {
    • return getCurrentSpeed() <= this.SPEED_LIMIT;
    • }
    • }

making it verbose and using camel case.

Code
Diff
  • public class Program
    {
        public static int returnInputNumber(int num)
        {
          return num;
        }
    }
    • public class Program
    • {
    • public static int GetValue(int i)
    • public static int returnInputNumber(int num)
    • {
    • return i;
    • return num;
    • }
    • }