티스토리 뷰
} else if (input.equals("4")) {
Random rd = new Random();
int ranNum = rd.nextInt(engArr.size());
String answer = engArr.get(ranNum);
String question ="";
ArrayList<String> tempArr = new ArrayList<String>();
for (int i = 0; i < answer.length(); i++) {
tempArr.add(answer.substring(i,i+1));
}
while(tempArr.size() > 0) {
ranNum = rd.nextInt(tempArr.size());
question = question + tempArr.get(ranNum);
tempArr.remove(ranNum);
}
String temp = answer;
// while(temp.length() > 0) {
// ranNum = rd.nextInt(temp.length());
// question = question + temp.substring(ranNum, ranNum+1);
// temp = temp.substring(0, ranNum) + temp.substring(ranNum+1);
// System.out.println("ranNum: "+ ranNum +", question: "+question +", temp: "+ temp);
// }
System.out.println("문제: "+ question);
input = scan.nextLine();
if(input.equals(answer)) {
//정답
}else {
//오답
}
'TEMP' 카테고리의 다른 글
Aug31_ 스케쥴러 만들기 (0) | 2020.08.31 |
---|---|
인터페이스(interface)_ 다중상속, 구현 (implementation) (0) | 2020.08.19 |
Side Project_포켓몬게임만들기 (0) | 2020.08.18 |
주말에 볼 것 (0) | 2020.08.18 |
homework_달력만들기 (Calendar) (0) | 2020.08.12 |
댓글