Hi all,
Wonder if someone could please lend a hand,
I have a courses.txt file which is read into a Course String array
I also have a program.txt (A list of 8 courses required to pass the program)
There's a menu option to change the Program, however a condition of that is
that the new program must contain only courses from the courses.txt (aka the courses array)
I can't seem to do that, any assistance would greatly be appreciated
Here is the code where courses are entered
try
{
courses[0] = new course();
for (int j = 0; j < 8; j++)
{
System.out.println("\n\nPlease enter the new course codes");
System.out.print("Program " + (j+1) +" >> ");
String tempCourse = input.next();
if (courses[0].checkCourse(tempCourse) == true)
{
tempCourse = programObjects[j];
}
else
{
System.out.print("Sorry that course is a listed course");
}
}
}
and the checkCourse method
public boolean checkCourse(String tempCourse)
{
boolean matched = false;
for (int i = 0; i < courseArrayLength; i++)
{
if (courseObjects[i].equals(tempCourse))
{
matched = true; //Matched Course Code
}
else
{
matched = false;
}
}
return matched;
}
After enter the first course I get "null" to the screen
which then causes it to go back to the menu, Is it to do with my courses[0] instance?
Thank you in advance!