티스토리 뷰

TEMP

temp_스크램블 게임

장꾸꾸 2020. 8. 12. 18:39
			} 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
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함