请大家帮忙看看下面的代码,编译可以通过,运行时却有很多问题
请大家帮忙看看下面的代码,编译可以通过,运行时却有很多问题
我是菜鸟,谢谢指点!!
import java.awt.*;
import javax.swing.*;
class FallChar
{
public int x,y,v;
public String s;
public void FallChar()
{ x=(int)Math.random()*400;
x=10*(Math.round(x/10f));
y=-(int)Math.random()*100;
v=(int)Math.random()*10;
s=""+(char)(int)(Math.random()*26+65); //Get a Random char between A~Z
}
public void fall()
{ y+=v;
if(y>300+24)
{ y=-(int)Math.random()*100;
x=(int)Math.random()*400;
x=10*(Math.round(x/10f));
}
}
}
public class Matrix extends javax.swing.JApplet implements Runnable
{
FallChar[] fc=new FallChar[256];
Thread runner;
public void init()
{
}
public void start()
{ if(runner==null)
runner=new Thread(this);
runner.start();
}
public void paint(Graphics g)
{ Graphics2D gg=(Graphics2D)g;
gg.setColor(Color.black);
gg.fillRect(0,0,400,300);
gg.setColor(Color.green);
gg.drawString("http://goomoo.uuoo.com",10,20);
System.out.println("http://goomoo.uuoo.com");
gg.drawString(fc[0].s,10,50);
for(int i=0;i<fc.length;i++)
{ g.drawString(fc[i].s,fc[i].x,fc[i].y);
}
}
public void run()
{
while(true)
{
for(int i=0;i<fc.length;i++)
{ fc[i].fall();
System.out.print(""+fc[i].y);
}
this.repaint();
try
{ runner.sleep(100);
}
catch(InterruptedException e){};
}
}
}
我是菜鸟,谢谢指点!!
import java.awt.*;
import javax.swing.*;
class FallChar
{
public int x,y,v;
public String s;
public void FallChar()
{ x=(int)Math.random()*400;
x=10*(Math.round(x/10f));
y=-(int)Math.random()*100;
v=(int)Math.random()*10;
s=""+(char)(int)(Math.random()*26+65); //Get a Random char between A~Z
}
public void fall()
{ y+=v;
if(y>300+24)
{ y=-(int)Math.random()*100;
x=(int)Math.random()*400;
x=10*(Math.round(x/10f));
}
}
}
public class Matrix extends javax.swing.JApplet implements Runnable
{
FallChar[] fc=new FallChar[256];
Thread runner;
public void init()
{
}
public void start()
{ if(runner==null)
runner=new Thread(this);
runner.start();
}
public void paint(Graphics g)
{ Graphics2D gg=(Graphics2D)g;
gg.setColor(Color.black);
gg.fillRect(0,0,400,300);
gg.setColor(Color.green);
gg.drawString("http://goomoo.uuoo.com",10,20);
System.out.println("http://goomoo.uuoo.com");
gg.drawString(fc[0].s,10,50);
for(int i=0;i<fc.length;i++)
{ g.drawString(fc[i].s,fc[i].x,fc[i].y);
}
}
public void run()
{
while(true)
{
for(int i=0;i<fc.length;i++)
{ fc[i].fall();
System.out.print(""+fc[i].y);
}
this.repaint();
try
{ runner.sleep(100);
}
catch(InterruptedException e){};
}
}
}
...全文
相关推荐
luadec反编译方法
虽然`luadec`不能百分之百还原原始代码,但它仍然是一个非常有用的工具,特别是在进行代码调试或逆向工程时。如果您还有其他疑问或遇到问题,欢迎随时查阅更多相关文档或寻求社区帮助。
fortran编译器使用指南
可以通过 `Start Page` 新建项目,如果没有显示起始页,请通过 `View -> Start Page` 显示它。2. **输入代码并运行** - 在 VS 中输入 Fortran 代码。
c代码-输入总秒数,转换为相应的时、分、秒。提示:在输出时,请使用下面的格式(变量名不要求一样)printf("%d:%.2d:%.2d\n", h, m, s) 输入:整数 输出:时分秒,整数,西文冒号分隔。
为了编译和运行这个程序,你可以使用`gcc`命令,例如`gcc main.c -o convert_time`,然后通过`./convert_time`来执行生成的可执行文件。
解决idea使用maven编译正常但是运行项目时却提示很多jar包找不到的问题
使用IDEA和Maven可以方便地进行项目开发和管理 HOWEVER,有时在使用IDEA和Maven进行项目编译和运行时,却会出现一些问题,本文将详细介绍解决IDEA使用Maven编译正常但是运行项目时却提示很多
java的编译时多态和运行时多态
编译时多态编译时多态是指在编译期根据参数列表的不同来区分不同的函数,这时编译器会将同名的函数名变为不同的函数名。在编译时,编译器会对代码进行分析和优化,生成相应的机器代码。


Java SE
