Хавьер Гонсалес заставил меня ответить.Я полностью удалил метод getCourse и переместил цикл for в оператор вывода.
Вот метод восстановления:
public class Course {
public static int a;
public static String code;
public static int CreditHours;
Course() {}
Course(int newA) {a = newA;}
, а вот оператор вывода:
public static void main(String[] args) {
System.out.println("Quenten's Copy");
System.out.println("course Objects each has a code (e.g. IT1006) and
credit hours (e.g. 6)");
System.out.println("The number inside the [] is the display order number");
System.out.println("The number inside the () is the credit hours");
for (int i = 1; i <= 7; i++) {
a = i;
System.out.println("[" + a + "] " + Course.getCode(code) + " (" + Course.getCreditHours(CreditHours) + ")");
}
}
}
Вот окончательный вывод:
course Objects each has a code (e.g. IT1006) and credit hours (e.g. 6)
The number inside the [] is the display order number
The number inside the () is the credit hours
[1] IT1006 (6)
[2] IT4782 (3)
[3] IT4789 (3)
[4] IT4079 (6)
[5] IT2230 (3)
[6] IT3345 (3)
[7] IT2249 (6)
Спасибо за помощь.Я не был уверен, как заставить цикл for работать должным образом, но теперь я понимаю, что он должен работать, пока происходит вывод.