91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 6KB
    文件類型: .java
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-05-16
  • 語言: Java
  • 標(biāo)簽: java??電梯??5層??

資源簡介

用java寫的5層電梯模擬實驗,包括開關(guān)門

資源截圖

代碼片段和文件信息

/**
?*?@author?楊一峰??09030228?2011.5.17
?*/
import?java.applet.*;
import?java.awt.*;
import?java.awt.event.*;

public?class?lift?extends?applet?implements?Runnable?ActionListener?{
Thread?thread;
private?static?final?int?UP?=?0;
private?static?final?int?DOWN?=?1;
private?static?final?int?OPEN?=?2;
private?static?final?int?CLOSE?=?3;
private?static?final?int?WAIT?=?4;

private?boolean?F1?=?false;
private?boolean?F2?=?false;
private?boolean?F3?=?false;
private?boolean?F4?=?false;
private?boolean?F5?=?false;
private?boolean?target?=?false;
private?boolean?painted?=?false;

private?int?state?=?WAIT;
private?int?t?currentfloor;
private?int?x?y?width?height?openxblock;

Image?BufferImage;
Graphics?BufferGraphics;
Button?f1?f2?f3?f4?f5;
Label?lab;

public?void?init()?{
setSize(300?500);
setLayout(null);
lab?=?new?Label(“0“);

f1?=?new?Button(“1“);
f2?=?new?Button(“2“);
f3?=?new?Button(“3“);
f4?=?new?Button(“4“);
f5?=?new?Button(“5“);

lab.setBounds(120?160?20?20);
f1.setBounds(200?160?30?30);
f2.setBounds(200?200?30?30);
f3.setBounds(200?240?30?30);
f4.setBounds(200?280?30?30);
f5.setBounds(200?320?30?30);

BufferImage?=?createImage(getSize().widthgetSize().height);
BufferGraphics?=?BufferImage.getGraphics();

currentfloor?=?0;
openx?=?0;
t?=?0;
x?=?20;
y?=?10;
width?=?80;
height?=?400;
block=20;

f1.addActionListener(this);
f2.addActionListener(this);
f3.addActionListener(this);
f4.addActionListener(this);
f5.addActionListener(this);

add(lab);
add(f1);
add(f2);
add(f3);
add(f4);
add(f5);
}

public?void?paint(Graphics?g)?{
BufferGraphics.setColor(Color.white);
BufferGraphics.fillRect(0?0?getSize().widthgetSize().height);
BufferGraphics.setColor(Color.black);
BufferGraphics.fillRect(x?y?+?9?width?+?1?height?+?3);
BufferGraphics.setColor(Color.white);
BufferGraphics.drawRect(x?+?1+block?y?+?height?/?5?*?4?-?t?+?10+block?(width?-?2)?/?2?-?openx-block
height?/?5-block);
BufferGraphics.fillRect(x?+?1?+?(width?-?2)?/?2?-?openx
y?+?height?/?5?*?4?-?t?+?10+block?openx?*?2?height?/?5?+?1-block);
BufferGraphics.drawRect(x?+?1?+?(width?-?2)?/?2?+?openx
y?+?height?/?5?*?4?-?t?+?10+block?(width?-?2)?/?2?-?openx-block
height?/?5-block);


if(state==UP)
BufferGraphics.setColor(Color.red);
else
BufferGraphics.setColor(Color.black);
BufferGraphics.drawString(“△“120?200);
if(state==DOWN)
BufferGraphics.setColor(Color.red);
else
BufferGraphics.setColor(Color.black);
BufferGraphics.drawString(“▽“120?220);
lab.setText(String.valueOf(currentfloor));
painted?=?true;
g.drawImage(BufferImage00this);
}
public?void?update(Graphics?g){
paint(g);
}
public?void?control()?{
if?(state?==?UP)?{
if?(t?==?y?+?height?/?5?*?4)
t?=?y?+?height?/?5?*?4;

評論

共有 條評論