If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Confused with this problem. Need Feedback and Guidance.adding and viewing information

Below is the problem I face :
View Places– The user selects a destination and the system displays all available Places at that destination. If there are no Places for a destination it should display a message to say so.

Add Place– Allows the user to add Place(s) for a given destination. This should add to the list of existing Placesfor that destination (if there are any). For example, the system might ask how many Places I wish to add; I might enter 2; and then I might add "tesco" and "asda". I do not know how to put the added Places into the view Places method :S

Im really confused on how to solve this problem. What i think i should do is to create two different methods for both problems. Whether i should use arrays and user can be asked to input Places which are stored in arrays.
below is what i have tryed. Would appreciate some help. UPDATE this is what ive tryed but i think its the wrong way to go about it. :

One step back.
Do you track places as well as hotels within places separately? Or just one, such as in Tokyo?
Arrays or collections are fine. Adding is more useful if you use a collection such as an ArrayList though. Arrays are not scalable, so if you add say two locations, then decide to add another two, you'll need to resize the array by creating a new array and then copying the existing data before inserting new data. Collections and Vectors excel at this since you can scale them both up and down very easily, and are typically iterated using the foreach style syntax.
You'll need to be handling a single (or multiple, not sure yet) arrays (or collection objects) for this. You can do so either at the class level by declaring a static array as a member property, OR you can create an array and pass it around from method to method to modify. Array pointer values are passed by reference in Java, but not the pointer itself (so you can modify an array within a function but you cannot modify what the array points at). So to keep it simple, I'd suggest either a collection OR a static class member that contains these.

PHP Code:

header('HTTP/1.1 420 Enhance Your Calm');

Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

Users who have thanked Fou-Lu for this post:

One step back.
Do you track places as well as hotels within places separately? Or just one, such as in Tokyo?
Arrays or collections are fine. Adding is more useful if you use a collection such as an ArrayList though. Arrays are not scalable, so if you add say two locations, then decide to add another two, you'll need to resize the array by creating a new array and then copying the existing data before inserting new data. Collections and Vectors excel at this since you can scale them both up and down very easily, and are typically iterated using the foreach style syntax.
You'll need to be handling a single (or multiple, not sure yet) arrays (or collection objects) for this. You can do so either at the class level by declaring a static array as a member property, OR you can create an array and pass it around from method to method to modify. Array pointer values are passed by reference in Java, but not the pointer itself (so you can modify an array within a function but you cannot modify what the array points at). So to keep it simple, I'd suggest either a collection OR a static class member that contains these.

Im thinking of creating an array list for each destination. But is it possible to pass on the array list to another method?

So when user selects the option Add places, the user can enter the places and then to view them the user then returns to menu and selects view hotels.

Yes, you can pass an ArrayList<T> object through a method parameter, or contain it as a static member. Both would be fine and you can alter it within each method without the mess of an array.
If you are tracking places within places (which I'm not sure if you are, but you may be. . .) such as a place within a city, than a good option may be to use a Map<String, ArrayList<String>> type. This would let you put on a city name, and have a list of places that can be added or iterated within it.

PHP Code:

header('HTTP/1.1 420 Enhance Your Calm');

Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)