此代码用于实现掷骰子游戏。我已经用这个程序测试了我所有的其他代码,它工作得很好。起初,我的驱动程序中有以下代码块,通过 Scanner 对象工作,但我的教授告诉我必须使用 BufferedReader。
这是代码:
import java.io.*;
import java.util.*;
public class Driver
{
/*
Dan Czarnecki
October 8, 2013
Class variables:
n/a
Constuctors:
n/a
Methods:
public static void main(String[] args)
Calls the necessary methods in the Craps class to simulate the game of craps
Modification history:
October 1, 2013
Original program
October 8, 2013
Fixed style issues
October 20, 2013
Fixed more style issues
Final version of program
*/
public static void main(String[] args)
{
BufferedReader br;
InputStreamReader isr;
br = new BufferedReader(isr);
int play;
System.out.println("Would you like to play craps? (1 for yes, 0 for no)");
play = br.nextInt();
if(play == 1)
{
Craps cr;
cr = new Craps();
System.out.println("The value of the roll is: " + cr.roll());
while(cr.gameOver() == false);
cr.roll();
}
else
{
System.out.println("See you later!");
}
}
}
我知道我现在使用 BufferedReader 重新实现它的方式是错误的,所以有人可以告诉我我应该如何实现它吗?