Carey Brown wrote:It's more likely that you'll want a method like this:
And
would then be
Also you have a variable called "substring" but it is in fact a String not a substring. 'schedule[index]' is a String. What does that String look like? I'm presuming that the string contains a course name and other stuff, so you'd use the substring() method to pluck out just the course name before you compare it to courseToFind.
Where are you populating the 'schedule' array?
Carey Brown wrote:It's more likely that you'll want a method like this:
And
would then be
Also you have a variable called "substring" but it is in fact a String not a substring. 'schedule[index]' is a String. What does that String look like? I'm presuming that the string contains a course name and other stuff, so you'd use the substring() method to pluck out just the course name before you compare it to courseToFind.
Where are you populating the 'schedule' array?
Carey Brown wrote:Your instructions don't say anything about using courseCredits as one of the searchCourse() method parameters. If/when you find the course your supposed to print out the course and the credits.
Your method needs to loop through all the entries in you schedule array. So far, unless you've changed it, you are not populating the array, so a search is not very meaningful.
Carey Brown wrote:Can you show us the current state of your searchCourse() method? Show the whole thing, don't cut off the beginning or end of the method.
You've allocated an array to hold the schedule up to 6 classes. You have not yet assigned a course to any of those 6 slots.
Also show us your addCourse() method.
All things are lawful, but not all things are profitable.
Knute Snortum wrote:You really need to format your code correctly. It is going to help your coding and debugging a lot.
You're calling the searchCourse() method like this:
But your method signature looks like this:
So you see you have declared the method to take two parameters but you call it with only one.
But before you change that, don't you want the method to return the courseName? If so, you should declare searchCourse() to return s String, then add a return statement to your searchCourse() method.
There are several other problems with the code, but let's start with that.
Okay, I'll be more explicit.Ed Palazo wrote:I'm not fully understanding what you want me to do exactly
All things are lawful, but not all things are profitable.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |