Ledger Nano X - The secure hardware wallet
SHARE
TWEET

ElevationInfo

APCS_IS_HARD Apr 9th, 2020 167 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. public class ElevationInfo {
  4.     // The array of elevations
  5.     private int[] elevations;
  6.  
  7.     // Constructor not shown
  8.     public boolean allUphill() {
  9.         for (int i = 0; i < elevations.length; i++) {
  10.             if (i != 0){
  11.                 if( elevations[i - 1] > elevations[i]) {
  12.                     return false;
  13.                 }
  14.             }
  15.         }
  16.         return true;
  17.     }
  18.  
  19.     public int amountOfClimb() {
  20.         int sum = 0;
  21.         for (int i : elevations) {
  22.             sum+=i;
  23.         }
  24.         return sum;
  25.     }
  26.  
  27.     public int highestPeakIndex() {
  28.         int max = 0;
  29.         for (int i : elevations) {
  30.             if (i > max){max = i;}
  31.         }
  32.         return max;
  33.     }
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top