Answer the question
In order to leave comments, you need to log in
Where do you need to write the values, when encapsulating, that are in a commented out variable so that they can all be displayed?
public class DayTest {
public static void main(String[] args) {
Day d = new Day(days[i]);
System.out.println();
}
}
class Day{
//int[] days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
private int[] days;
public Day(int[]days){
this.days = days;
}
public void setDays(int[] days){
this.days = days;
}
public int[] getDays(){
return days;
}
public int[] Days(){
int i = 0;
for(; i < days.length; i++){
}
return days;
}
}
Answer the question
In order to leave comments, you need to log in
Good afternoon!
Where do you think the value i
should come from here, which you pass to the constructor?
public static void main(String[] args) {
Day d = new Day(days[i]);
System.out.println();
}
Where do you need to enter the values, when encapsulating, that are in a commented out variable so that they can all be displayed?
private int[] days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
public int[] Days(){
int i = 0;
for(; i < days.length; i++){
}
return days;
}
After 2 lines. Insert what you have in the comments, well, pass days.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question