forked from exercism/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBirdWatcher.java
More file actions
61 lines (50 loc) · 1.86 KB
/
Copy pathBirdWatcher.java
File metadata and controls
61 lines (50 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class BirdWatcher {
private final int[] birdsPerDay;
public BirdWatcher(int[] birdsPerDay) {
this.birdsPerDay = birdsPerDay.clone();
}
public int[] getLastWeek() {
// throw new UnsupportedOperationException("Please implement the BirdWatcher.getLastWeek() method");
int[] birdCount = new int[] {0,2,5,3,7,8,4};
return birdCount;
}
public int getToday() {
// throw new UnsupportedOperationException("Please implement the BirdWatcher.getToday() method");
return birdsPerDay[birdsPerDay.length-1];
}
public void incrementTodaysCount() {
/// throw new UnsupportedOperationException("Please implement the BirdWatcher.incrementTodaysCount() method");
birdsPerDay[birdsPerDay.length-1] += 1;
}
public boolean hasDayWithoutBirds() {
// throw new UnsupportedOperationException("Please implement the BirdWatcher.hasDayWithoutBirds() method");
boolean noBird = false;
for(int count : birdsPerDay){
if (count == 0){
noBird = true;
}
}
return noBird;
}
public int getCountForFirstDays(int numberOfDays) {
// throw new UnsupportedOperationException("Please implement the BirdWatcher.getCountForFirstDays() method");
int getTotalCount=0;
if(numberOfDays>birdsPerDay.length){
numberOfDays = birdsPerDay.length;
}
for(int i=0;i<numberOfDays;i++){
getTotalCount += birdsPerDay[i];
}
return getTotalCount;
}
public int getBusyDays() {
// throw new UnsupportedOperationException("Please implement the BirdWatcher.getBusyDays() method");
int busyDays=0;
for (int count : birdsPerDay){
if(count >= 5) {
busyDays++;
}
}
return busyDays;
}
}