프로그램 한번 봐주세요 에러가 많아서요


[ 다음 글들 ] [ 이어서 글올리기(답하기) ] [ 자바 묻고 답하기 ]

글쓴이 :양지현 1999년 12월 09일 14:44:53

프로그램이 전체적으로 잘못된것 같은데요
잘 모르겠어요 좀 도와주세요 레포트거든요
선수과목을 안듣고 들어서 더 헤메고 있습니다 시간되시면 고쳐서 제게 이멜을 주시면
감사감사 하겠지만....
앞으로 자바공부열심히할라구요 도와 주시면 감사드릴께요

import java.io.*;
import java.util.*;


//main()함수를 갖고 있으며 그안에서 전체게임을 주관하는 클래스
//한번게임을 수행할때마다 게임의 끝에가서 계속 여부를 물어 사용자가 중지를 원할때까지 계속게임수행.



public class SRPPlay {
public static void main(String[] args) {
HumanPlayer hp = new HumanPlayer();
ComputerPlayer cp = new ComputerPlayer();
boolean keep = true;

static finalMax_Game = 20;//최대 게임수
int try_num = 0; //현재까지의 게임 횟수
int [Max_Game]choice = 0;//컴퓨터에 선택을 저장
string ChoiceToString(int choice);//선택사항을 주면 스트링으로 바꾸어 반환
void print (string s, int i);//현재 컴퓨터가 낸 결과를 화면에 출력
int make_choice();
//가위바위보(메세지 출력 가위는1 바위는2 보는 3입니다)중 하나를 선택하여 반환(return)

while(keep && try_num++ < Max_Game) {
System.out.println();
int hpNum = hp.makeChoice();
int cpNum = cp.makeChoice();

hp.print("Human", hpNum);
cp.print("Computer", cpNum);


switch(hpNum) {
case 1:
if(cpNum == 1) {
System.out.println("A drawn game.");
} else if(cpNum == 2) {
System.out.println("You win.");
} else if(cpNum == 3){
System.out.println("You lose.");
score += 5;
}
break;
case 2:
if(cpNum == 2) {
System.out.println("A drawn game.");
} else if(cpNum == 1) {
System.out.println("You win.");
} else if(cpNum == 3){
System.out.println("You lose.");
score += 5;
}
break;
case 3:
if(cpNum == 3) {
System.out.println("A drawn game.");
} else if(cpNum == 2) {
System.out.println("You win.");
} else if(cpNum == 1){
System.out.println("You lose.");
score += 5;
}
break;
default:
System.out.println("A drawn game.");
}

char ch;
System.out.print("continue(EXIT: n continue:아무키나) ? ");
StringBuffer str = new StringBuffer();
try {
while((ch = (char)System.in.read()) != '\n') {
str.append(ch);
}
} catch(IOException e) {
System.err.println("IOException : " + e);
}

if(str.charAt(0) == 'n'){
break;
}

}//end of while

System.out.println("당신의 점수는 " + score + "점 입니다.");
}//end of main
}



public class AbstractPlayer{

static final Max_game = 20 // 최대게임수
int try_num = 0; //현재까지의 게임횟수
int[Max_Game]choice; // 사람의 선택 저장
String ChoiceToString(int choice); //선택사항을 주면 스트링으로 바꾸어 반환
void print(String s,int i); //현재 사람이 낸 결과를 화면에 출력
int make_choice(); //가위바위보중 하느를 사람에서 선택하게 한후 그결과를 반환
}



public class HumanPlayer extends AbstractPlayer {
//가위바위보중 하나를 사람에서 선택하게 한후 그결과를 반환(return)
public int makeChoice() {
BufferedReader stdin = new BufferedReader
(new InputStreamReader(System.in));

try {
System.out.print("1.가위 2.바위 3.보 ... ? ");
int choice = Integer.parseInt(stdin.readLine());
}//try
catch(IOException exception){
System.out.println("죄송합니다!! Error가 발생하였습니다.");


} // catch



int choice = str.charAt(0) - 48;
if(try_num < Max_Game) {
choices[try_num] = choice;
}
try_num =+ 1;

return choice;
}
}




public class ComputerPlayer extends AbstractPlayer {


public int makeChoice() {
Random ran = new Random((int) System.currentTimeMillis());

int choice = Math.abs(ran.nextInt()) % 3 + 1;

if(try_num < Max_Game) {
choices[try_num] = choice;
}
try_num =+ 1;

return choice;
}
}



다음 글들:



이어서 글올리기(답하기)

이름:
E-Mail:
제목:
내용:
HTML 태그 포함 여부: HTML 문서일 경우 체크
관련 URL(선택):
URL 제목(선택):
관련 이미지 URL:


[ 다음 글들 ] [ 이어서 글올리기(답하기) ] [ 자바 묻고 답하기 ]