-
-
Notifications
You must be signed in to change notification settings - Fork 354
/
Copy pathExemplar.cs
58 lines (46 loc) · 946 Bytes
/
Exemplar.cs
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
using System;
class BirdCount
{
private int[] birdsPerDay;
public BirdCount(int[] birdsPerDay)
{
this.birdsPerDay = birdsPerDay;
}
public static int[] LastWeek()
{
return new int[] { 0, 2, 5, 3, 7, 8, 4 };
}
public int Today()
{
return birdsPerDay[6];
}
public void IncrementTodaysCount()
{
birdsPerDay[6]++;
}
public bool HasDayWithoutBirds()
{
return Array.IndexOf(birdsPerDay, 0) != -1;
}
public int CountForFirstDays(int numberOfDays)
{
var total = 0;
for (var i = 0; i < numberOfDays; i++)
{
total += birdsPerDay[i];
}
return total;
}
public int BusyDays()
{
var days = 0;
foreach (var count in birdsPerDay)
{
if (count >= 5)
{
days++;
}
}
return days;
}
}