Topic: 菜鸟提问:我的这个程序怎么通不过:?

  Print this page

1.菜鸟提问:我的这个程序怎么通不过:? Copy to clipboard
Posted by: heidi
Posted on: 2005-05-04 14:40

我是个新手,没什么编程经验,今天照着书上的例子用记事本写了程序如下,
用“javac lot.java" 编译通不过。
提示好像是没有找到我写的那个接口和方法
请帮我看看有什么语法错误吗?
怎么才能让他通过呢?

内容如下:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class lot extends Applet implements Actionlistener
{
Label result;
TextField in1;
Button btn;
TextArea area;

int i,j,k,l,m,total;
int num [] [];

public void init()
{
result=new Label("请先输入机选注数");
in1=TextField(5);
btn=Button ("投注");

add(in1);
add(btn);
add(result);
add(area);
btn.addActionListener(this);
}

public void actionperformed(ActionEvnent e)
{
total=Integer.parseInt(in1.getText());
num=new int[total][7];

for(i=0;i<total;i++)
{
m=i+1;
area.append("第"+m+"注: "+"\t");
for(j=0;j<7;j++)
{
num[i][j]=(int)(Math.random()*36)+1;
for(k=0;k<j;k++)
{
if(num[i][j]==num[i][k])
num[i][j]=(int)(Math.random()*36)+1;
}
area.append(num[i][j]+"\t");
}
area.append("\n");
}
}
}

2.Re:菜鸟提问:我的这个程序怎么通不过:? [Re: heidi] Copy to clipboard
Posted by: mesocool
Posted on: 2005-05-06 00:42

"ActionListener" L大写。。

3.Re:菜鸟提问:我的这个程序怎么通不过:? [Re: heidi] Copy to clipboard
Posted by: Yipcong
Posted on: 2005-05-07 00:14

注意接口和方法的大小写:
ActionListener{
void actionPerformed(ActionEvent e){
}
}

4.Re:菜鸟提问:我的这个程序怎么通不过:? [Re: heidi] Copy to clipboard
Posted by: 一枝梅
Posted on: 2005-05-13 11:04

class lo类名也要大写

5.Re:菜鸟提问:我的这个程序怎么通不过:? [Re: heidi] Copy to clipboard
Posted by: eatingfood
Posted on: 2005-05-14 00:49

editplus
建议写程序的时候用这个````
比用记事本方便多了

6.Re:菜鸟提问:我的这个程序怎么通不过:? [Re: heidi] Copy to clipboard
Posted by: why
Posted on: 2005-05-14 09:13

"area" is not initialized!


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

public class Lot extends Applet implements ActionListener {
  Label result;

  TextField in1;

  Button btn;

  TextArea area;

  int i, j, k, l, m, total;

  int num[][];

  public void init() {
    result = new Label("请先输入机选注数");
    in1 = new TextField(5);
    btn = new Button("投注");
    area = new TextArea();

    add(in1);
    add(btn);
    add(result);
    add(area);
    btn.addActionListener(this);
  }

  public void actionPerformed(ActionEvent e) {
    total = Integer.parseInt(in1.getText());
    num = new int[total][7];

    for (i = 0; i < total; i++) {
      m = i + 1;
      area.append("第" + m + "注: " + "\t");
      for (j = 0; j < 7; j++) {
        num[i][j] = (int) (Math.random() * 36) + 1;
        for (k = 0; k < j; k++) {
          if (num[i][j] == num[i][k])
            num[i][j] = (int) (Math.random() * 36) + 1;
        }
        area.append(num[i][j] + "\t");
      }
      area.append("\n");
    }
  }
}


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923