Sander Hoovenaar wrote:I thought it would be a good idea to model these cities in an Enum. The amount of cities will be limited (I will not use larger sets of cities than a size of 20 cities).
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Sander Hoovenaar wrote:I thought it would be a good idea to model these cities in an Enum. The amount of cities will be limited (I will not use larger sets of cities than a size of 20 cities).
The main problem I would see with that is that it's not very scaleable. Specifically: what if later on you decide that you do want to have more than 20? You then have to change a source file to allow any new cities, whereas if you stored the data in a file, you could simply load it at start-up...
(...) which you could then use as a key to a Map<String, City>.
Sander Hoovenaar wrote:The map would then be an arrayList (since you use <>)?
As I mentioned above, my model will certainly not consist of more than 20 cities, and none of the cities I'll put in now, will change. The reason I looked at enum is to make sure that input is limited to the list of predetermined cities. Would that be possible in other methods too?
Sander Hoovenaar wrote:The reason I looked at enum is to make sure that input is limited to the list of predetermined cities. Would that be possible in other methods too?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
All things are lawful, but not all things are profitable.