Basically I'm making this Java program in BlueJ, in which the player is in the world of The Lord of the Rings. I created separate packages for weapons, items etc. I have a class Main outside all the packages(in the main body of the project screen). In there, I tried something.
public static void test()throws Exception{
System.out.println("There is a brass sword and an iron sword. Which do you want?");
Scanner in = new Scanner(System.in);
String s = in.next();
HashMap options = new HashMap();
options.put("brass", new Sword());
options.put("iron", new Sword());
Sword k = options.get(s);
}
I want the above method to return a Sword object to me. This does not work, unfortunately. Any help....?
HashMap.