0
무기 상점과 비슷한 Java로 게임을 작성하기 시작했습니다. 사용자가 콘솔 내에서 HashMap에 인쇄 된 항목을 선택할 수있게하려고합니다. 사용자가 항목을 선택하고 강조 표시하면 사용자는 해당 항목을 구매했을 것입니다. 거기에 내장 된 유틸리티 Java가 이것을 지원 하는가? 다음은 내가 가지고있는 것입니다.Java 강조 표시 및 입력 선택
public static int purchaseMedicine(int goldAmount) {
HashMap<String, Integer> map = new HashMap<String, Integer>();
map.put("Jewel of Open", 500);
map.put("Potion", 800);
map.put("Hi-Potion", 2000);
map.put("Elixir", 8000);
map.put("Manna Prism", 4000);
map.put("Antivenom", 200);
map.put("Hammer", 200);
map.put("Library Card", 500);
int index = 0;
for(Map.Entry<String, Integer> entry : map.entrySet()) {
System.out.println(entry.getKey() + " " + entry.getValue());
}
System.out.printf("\n\tGold %d\n\n", goldAmount);
return index; // Returns the instances of medicineList
}