Bird watcher

in #italast month

using System;

class BirdCount
{
public int[] birdsPerDay = new int[7] { 0, 2, 5, 3, 7, 8, 4 };

public BirdCount(int[] birdsPerDay)
{
    this.birdsPerDay = birdsPerDay;
}

public static int[] LastWeek()
{
   int[] birdsPerDay1 = new int[7] { 0, 2, 5, 3, 7, 8, 4 };
   return birdsPerDay1;
}

public int Today()
{
    return birdsPerDay[birdsPerDay.Length-1];
}

public void IncrementTodaysCount()
{
    int today=Today();
    today = today+1;
    birdsPerDay[birdsPerDay.Length-1]= today;
}

public bool HasDayWithoutBirds()
{
   // al posto di un for con un if dentro:https://stackoverflow.com/questions/21197410/c-sharp-compiler-error-not-all-code-paths-return-a-value
    return System.Array.IndexOf(birdsPerDay, 0) >= 0;
}

public int CountForFirstDays(int numberOfDays)
{
    int visitingBirds = 0;
    for (int i=0; i<= numberOfDays-1; i++)
    {
        visitingBirds += birdsPerDay[i];
    }
    return visitingBirds;
}

public int BusyDays()
{
    int busyDays = 0;
    for (int i=0; i<= birdsPerDay.Length-1; i++)
    {
        if(birdsPerDay[i] >= 5)
        busyDays += 1;
    }
    return busyDays;
}

}