Why have you got a
number field in the student class? You do not appear to use it for anything. Are you supposed to use that field to set the ID number? If you, you would not want to pass the ID to the constructor.
Have you got any way of getting courses from the student class? The question about which course a student enrols for sounds like something out of a database assignment, where you get a relation between student and course and you can query it both ways. You can search through all the courses for a particular student, but that is hardly an elegant or efficient solution. You can try a
bidirectional map, but that is probably too complicated for your level of experience.
You can add some way of recording courses inside the Student class, you can have students recorded in each course, and courses recorded in each student. You would have to set some sort of maximum, limiting how many courses each student may take at once. You need a method for each course which records a student, and a method for each student which records courses.
Those methods mustn’t be static. If you have a means of recording students, you must be able to add a student to the array, and also remove a student. Adding is quite easy, removing from an array slightly more difficult. If you go into your Java™ installation folder, you find a file called src.zip. Unzip that, go into the
java folder, the util folder, and the ArrayList.java file, and you can see how it is done there.
What happens when you change the capacity of the course? If you increase capacity, are you creating a new array and copying the students from the old array?
If you use an array, you don’t need a capacity field; you can use the length field of the array. Otherwise you are storing the same datum in two places and there is a risk of getting the two values different from each other. What happens if you reduce the capacity, say from 20 to 15, after 16 students have already enrolled?
You should consider what I have struck through and discuss it with your teacher.
Do you really want to change the ID in a student object?
How are you going to print out the details of a student or a course? Have you got
toString() methods ready to write? I would remind you not to use the + operator on Strings in more than one line; use a StringBuilder instead.
I have made lots of suggestions. Lots and lots. You will have to implement them. Take it easy and don’t let a 2-inch block of solid text on screen scare you. You implement those suggestions one at a time, not writing more than 5 lines of code before you compile and run it. You need a class with some sort of method which creates Student objects, prints their details, changes their details, enrols them on courses, etc., etc. You build up this method one line at a time, running it frequently . . . and when you finish that, you have got half your “testing class” ready-made