Carey Brown wrote:
rian bron wrote:
First, I'd suggest replacing both your while() loops with for() loops, just like the one on line 8. This will solve your biggest issue. You will still be left with the problem that line 28 does not properly check to see if the name wasn't found. For that I would suggest adding a boolean variable just above your search loop, like:
And please clean up your indentation, it is contributing to your inability to follow your own code.
Daniel Demesmaecker wrote:cause i is already the length of the array by the first time it get's to the second while loop, so that loop is never executed.
Change your second while loop to:
What is Strings? A class you created yourself? What a terrible name...
Knute Snortum wrote:
rian bron wrote:can you show me the way i will get the output of the "cityName" and not the output saying "There was no match inside the citise array to the name "+cityName;"
i'm so lost
Well, I'm not sure why you would need the variable test at all. Why not use cities?
Daniel Demesmaecker wrote:No you don't, the class you thin you initialize is test and the class that returns the array is tester, even if you would Knute is still right...
You have to break out of the loop once you found the right value...
Knute Snortum wrote:Take a look at this:
Go through it step by step. Keep in mind what tempName will be. What happens if cityName isn't the last element in your array?
Daniel Demesmaecker wrote:cause you're searching for the city in an empty array of cities.
You don't initialize the values of the array.
Note, this is the 4th or 5th question you ask about the same subject, but after getting some response you never let us know if you got it working, a little feedback or thanks on the responses you get would be nice...
Liutauras Vilda wrote:
rian bron wrote:ignore the variable naming thing, i did it because i didn't have much time
Your saved 13 keystrokes saving your own time caused Your Code Readers who want you to help to waste their time deciphering what those variables mean, so really to ignore the things are difficult, especially if readers are not informed upfront if they are relevant or not. If you want your readers to ignore the parts of the code, simply don't post them.
Please post the declaration of the Country class constructor, so the problem would be more apparent to discuss. But in general I think I've explained what I think the problem is, however, I could be mistaken due to insufficient visibility of the Country class, and in particular its constructor declaration.
Liutauras Vilda wrote:This code is very very confusing and hard to read.
On line 37 to Country constructor you are trying to pass singular city ci[j], while I suspect constructor is expecting an array of cities.
Anyway, you have been taught some bad concepts initially probably (for example, naming variables, i.e.: c stands for countries and ci for cities. Why not countries and cities?) that you came up with such code.
I'd delete that and start over. To suggest something, we'd need to know what is the task about in general.