Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions solutions/csharp/bird-watcher/1/BirdWatcher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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()
{
foreach(int day in birdsPerDay){
if(day == 0)
return true;
}
return false;
}

public int CountForFirstDays(int numberOfDays)
{
int numOfBirds = 0;
for(int day = 0; day < numberOfDays; day++){
numOfBirds += birdsPerDay[day];
}
return numOfBirds;
}

public int BusyDays()
{
int busyDays = 0;
foreach(int day in birdsPerDay){
busyDays += day >= 5 ? 1 : 0;
}
return busyDays;
}
}