- The bird count per day is stored in a field named
birdsPerDay. - The bird count per day is an array that contains exactly 7 integers.
- As we keep the last week we just need to return the last week values.
- Remember that the counts are ordered by day from oldest to most recent, with the last element representing today.
- Accessing the last element can be done either by using its (fixed) index (remember to start counting from zero) or by calculating its index using the array's size.
- Set the element representing today's count to today's count plus 1.
- The
Arrayclass has a built-in method that returns the first index where the element is found, or -1 if no matching element was found.
- A variable can be used to hold the count for the number of visiting birds.
- The array can be iterated over using a
forloop. - The variable can be updated inside the loop.
- Remember: arrays are indexed from
0.
- A variable can be used to hold the number of busy days.
- The array can be iterated over using a
foreachloop. - The variable can be updated inside the loop.
- A conditional statement can be used inside the loop.