목차
1. Multiply.java (Java 소스 파일)
2. Multiply.class (Java 클래스 파일)
4.94KB
2. Multiply.class (Java 클래스 파일)
4.94KB
본문내용
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Calculation{ //곱셈 게임 클래스
int result, result2, val, input_num, cnt=0, ver=0;
/*변수 설명
result : 랜덤 첫째값
result2 : 랜덤 둘째값
val : result와 result2를 곱한 결과 값
intput_num : 사용자가 입력한 값
cnt : 게임을 끝내기위한 카운트변수
ver : 게임의 단계를 고를 때 쓰는 변수
*/
//게임 실행이 실제적으로 이루어지는 메소드(x, y 값을 인수로 받는다)
public void gob(int x, int y)throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
while(cnt<10) //cnt변수가 0~9까지 증가할 동안. 즉 , 10회를 반복한다.
{
result = x+(int)(Math.random()*y); //랜덤함수를 이용해서 변수에 저장
//↑게임 단계에 따라 x, y인수를 달리 입력받는다. 인수 입력은 메인클래스에서 수행하고 있다.
result2 = 1+(int)(Math.random()*9);
val = result*result2;
System.out.print(result); delay(100);
System.out.print(\\\\" X \\\\"); delay(50);
System.out.print(result2); delay(100);
System.out.print(\\\\" ? \\\\"); delay(100);
import java.io.IOException;
import java.io.InputStreamReader;
class Calculation{ //곱셈 게임 클래스
int result, result2, val, input_num, cnt=0, ver=0;
/*변수 설명
result : 랜덤 첫째값
result2 : 랜덤 둘째값
val : result와 result2를 곱한 결과 값
intput_num : 사용자가 입력한 값
cnt : 게임을 끝내기위한 카운트변수
ver : 게임의 단계를 고를 때 쓰는 변수
*/
//게임 실행이 실제적으로 이루어지는 메소드(x, y 값을 인수로 받는다)
public void gob(int x, int y)throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
while(cnt<10) //cnt변수가 0~9까지 증가할 동안. 즉 , 10회를 반복한다.
{
result = x+(int)(Math.random()*y); //랜덤함수를 이용해서 변수에 저장
//↑게임 단계에 따라 x, y인수를 달리 입력받는다. 인수 입력은 메인클래스에서 수행하고 있다.
result2 = 1+(int)(Math.random()*9);
val = result*result2;
System.out.print(result); delay(100);
System.out.print(\\\\" X \\\\"); delay(50);
System.out.print(result2); delay(100);
System.out.print(\\\\" ? \\\\"); delay(100);
소개글