Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- public class ElevationInfo {
- // The array of elevations
- private int[] elevations;
- // Constructor not shown
- public boolean allUphill() {
- for (int i = 0; i < elevations.length; i++) {
- if (i != 0){
- if( elevations[i - 1] > elevations[i]) {
- return false;
- }
- }
- }
- return true;
- }
- public int amountOfClimb() {
- int sum = 0;
- for (int i : elevations) {
- sum+=i;
- }
- return sum;
- }
- public int highestPeakIndex() {
- int max = 0;
- for (int i : elevations) {
- if (i > max){max = i;}
- }
- return max;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement