у меня 3 класса. Я пытаюсь установить переменную в методе main через объект «main» и повторно использовать это значение, написав super.getnumberofsets (); в цикле for, но там написано "пропущена 1 из 2 веток".
public static void main(){
//in the main method
//Main class maintain the private variables with their setters and getters.
Main main = new Main();
Sets sets = new Sets();
System.out.print("Enter how many sets you want to create: ");
newnumberofsets = in.nextInt();
main.set_numberofsets(newnumberofsets);
sets.setgroups();
sets.getgroups();
}
// in Sets class
protected void setgroups()
{
//In this loop it says "1 of 2 branches missed".
for(int x = 0; x<super.getnumberofsets();x++) {
main_zeroarray[x] = new Main0();
}
}
protected void getgroups() {
count = 1;
for(int x = 0 ;x < super.getnumberofsets();x++) {
System.out.println(count + ". Set " + setnames[x]);
count++;
}
}
Я ожидал, что ключевое слово super прочитает то же значение из объекта main.set_newnumberofsets (newnumberofsets);