주사위게임
본 자료는 2페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
해당 자료는 2페이지 까지만 미리보기를 제공합니다.
2페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

주사위게임에 대한 보고서 자료입니다.

본문내용

s.score;
}
public void takeTurn(){
ArrayList list = new ArrayList();
int dice_value = 0;
boolean duplicate = false;
for(;;) {
Iterator i = list.iterator();
dice_value = dice.nextToss();
if(list.isEmpty() == true) {
System.out.print("\t\tYou first roll is ");
} else {
System.out.print("\t\tYou next roll is ");
}
while(i.hasNext()) {
int temp;
temp = ((Integer)i.next()).intValue();
if(temp == dice_value) {
duplicate = true;
}
}
if(duplicate == true) {
System.out.println(dice_value + " - A MATCH!");
break;
} else {
list.add(new Integer(dice_value));
System.out.print(dice_value + " \tRoll Again?(y/n): ");
if(rollAgain() == false) {
score += dice_value;
break;
}
}
}
}
}
Dice.java
import java.util.*;
public class Dice {
private Random random;
private Die die1;
private Die die2;
public Dice(Random random) {
die1 = new Die(random);
die2 = new Die(random);
}
public int nextToss() {
return die1.nextToss() + die2.nextToss();
}
}
Die.java
import java.util.*;
public class Die {
private Random random;
public Die(Random random) {
this.random = random;
}
public int nextToss() {
int random_value = 0;
while(random_value <= 0) {
random_value = random.nextInt() % 6;
}
return random_value + 1;
}
}

키워드

  • 가격1,300
  • 페이지수6페이지
  • 등록일2007.05.31
  • 저작시기2007.4
  • 파일형식한글(hwp)
  • 자료번호#412194
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니