Boolean
arrays are automatically initialized to false
.
So just after constrution no days have valid data.
public class Month { // instance variables private int month; // 1 == January private int year; // year as an int, eg 2017 private int daysInMonth; // number of days in this month // temperature data private int[] temp; // day 1 in temp[1] private boolean[] valid; // constructors public Month( int month, int year) . . . // Getters and Setters public int getTemp( int dayNumber ) { } public boolean setTemp( int dayNumber, int temp ) { } }
Fill in the methods. Do some error checking.
Think about dayNumber
being out of range and invalid temperatures.