java 问题,急!!

来源:百度知道 编辑:UC知道 时间:2024/07/07 13:01:57
import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class S3 extends JApplet{

final int WON = 0, LOST = 1, CONTINUE = 2;

boolean firstRoll = true;
int sumOfDice = 0;
int myPoint = 0;
int gameStatus = CONTINUE;
int c=0;
int w[] = new int [14];
int l[] = new int [14];

public void init() {

for(int counter=1;counter<=1000;counter++){

playGame();

}

String output = "win\tFrequency\tlost\tFrequency\n";

for ( int rating = 1; rating < w.length; rating++ )
output += rating + "\t" + w[ rating ] +"\t"+rating + "\t" + l[ rating ] +"\n";

JTextArea outputArea = new JTextArea();
outputArea.setText( output );

J

没看太明白你的代码功能,下面这个写法只是猜的,你试下是不是你要的结果

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class S3 extends JApplet{

final int WON = 0, LOST = 1, CONTINUE = 2;

boolean firstRoll = true;
int sumOfDice = 0;
int myPoint = 0;
int gameStatus = CONTINUE;
int c=0;
int w[] = new int [14];
int l[] = new int [14];

public void init() {

for(int counter=1;counter<=1000;counter++){
// 把playGame()里的rollDice放到这里
sumOfDice = rollDice();
playGame();

}

String output = "win\tFrequency\tlost\tFrequency\n";

for ( int rating = 1; rating < w.length; rating++ )
output += rating + "\t" + w[ rating ] +"\t"+rating + "\t" + l[ rating ] +"\n";

JTextArea outputArea = new JTextArea();
outputArea.setText( output )