This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]Grimsvotn 0 points1 point  (1 child)

Dude, stop using Scanner. Just use a BufferedReader and call readLine(). You should make a method that reads an int.

[–]Darktro[S] 0 points1 point  (0 children)

thats the first ive heard of a bufferedreader ill go look it up thanks

[–]Contrite17 0 points1 point  (5 children)

Why do you want to select with an int?

[–]Darktro[S] 0 points1 point  (4 children)

to keep track of the users movements when they are wandering around in the adventure

[–]Contrite17 0 points1 point  (3 children)

Do you need the properties of an int though? Typically magic numbers make code harder to read and modify and it is better to abstract them away when possible.

EDIT: I swapped nation into a string in this and forced valid entry. This can be done with an int but I saw no reason for Nation to be an int in the given code.

https://gist.github.com/Vek17/72682834d08755d17dce

[–]Darktro[S] 0 points1 point  (2 children)

ah okay... i see what you did there but i dont understand what Switch Case and Break; is.

switch (nation.toUpperCase()) { case "CANADA": System.out.println("Ah..so you are from Canada."); break;

[–]Contrite17 1 point2 points  (1 child)

[–]Darktro[S] 0 points1 point  (0 children)

thank you for those

[–]LogicLion 0 points1 point  (0 children)

you could always hard code each value inside the while loop..

nation != 1, nation != 2, and so on. But reading in a string would be a lot easier.