java课程设计风扇
⑴ Java课程设计
感觉不是特别麻烦。
文件系统是什么?就是读取个特殊文件吗?要解码?
界面建议你就用windowbuilder直接做吧,简单点。
要看到结果,选择题的好看,问题怎么判断。再来个论述题。
把要求写详细点。
⑵ 用java实现一个风扇的转动,具体代码如下,可是运行却不转动,请高手帮帮忙
class FengS
{
int fd = 0;
int ft = 0;
FengS(int d, int t)
{
.fd = d;
this.ft = t;
}
void run()
{
if(fd == 0)
{
System.out.println("风扇停止运行");
}
else if (fd == 1)
{
System.out.println("风扇一档运行");
}
else if (fd == 2)
{
System.out.println("风扇二档运行");
}
else if (fd == 3)
{
System.out.println("风扇三档运行");
}
else
System.out.println("风扇档数出错");
}
void tRun()
{
if (ft == -1)
{
this.run();
}
else if(60>= ft && ft> 0)
{
for (int a = 0; a<ft ; )
{
this.run();
System.out.println("剩余时间:"+ft+"分");
ft--;
}
System.out.println("风扇停止运行");
}
else if (ft == 0)
{
System.out.println("风扇停止运行");
}
else
System.out.println("风扇定时出错");
}
}
class Feng
{
public static void main(String[] args)
{
FengS fs = new FengS(3,60);
fs.tRun();
}
}
⑶ Java 编写一个表示风扇Fans的类,成员变量有:
|代码如下:
classFans{
privateintspeed;
privatebooleanon;
privatedoubleradius;
privateStringcolor;
publicFans(intspeed,booleanon,doubleradius,Stringcolor){
();
setSpeed(speed);
setOn(on);
setRadius(radius);
setColor(color);
}
publicintgetSpeed(){
returnspeed;
}
publicvoidsetSpeed(intspeed){
if(speed<1||speed>3){
("不正确的速度。");
}
this.speed=speed;
}
publicbooleanisOn(){
returnon;
}
publicvoidsetOn(booleanon){
this.on=on;
}
publicdoublegetRadius(){
returnradius;
}
publicvoidsetRadius(doubleradius){
this.radius=radius;
}
publicStringgetColor(){
returncolor;
}
publicvoidsetColor(Stringcolor){
this.color=color;
}
@Override
publicStringtoString(){
Stringstr="";
str+="风扇为"+(on?"打开":"关闭")+"状态,";
str+="风速为";
if(speed==1){
str+="快";
}elseif(speed==2){
str+="中";
}elseif(speed==3){
str+="慢";
}
str+=",半径是"+radius;
str+=",颜色为"+color;
returnstr;
}
}
publicclassApp{
publicstaticvoidmain(String[]args){
Fansfans=newFans(1,true,10,"灰色");
System.out.println(fans);
}
}
⑷ JaVa:创建一个名为Fan的类来模拟风扇
public class FanDemo{
private Fan fan;
}
class Fan{
private int speed;
private boolean on;
private double radius;
public Fan() {
}
public Fan(int speed, boolean on, double radius) {
super();
this.speed = speed;
this.on = on;
this.radius = radius;
}
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
public boolean isOn() {
return on;
}
public void setOn(boolean on) {
this.on = on;
}
public double getRadius() {
return radius;
}
}
⑸ 用java做个风扇,求帮助
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import java.applet.AudioClip;
public class Fan extends JFrame implements ActionListener{
static int time=1;
static int ti;
Timer time_1 = new Timer(100,this);
x1 x=new x1() ;
static TransPane jp;
JButton add=new JButton("加速");
JButton stop=new JButton("暂停/开始");
JButton low=new JButton("减速");
JButton dingshi=new JButton("定时1分钟");
JTextField TextIn = new JTextField("100");
JPanel p=new JPanel();
public Fan(){
super("旋转");
add(jp);
p.setLayout(new FlowLayout(FlowLayout.CENTER,30,30));
p.add(add);
p.add(stop);
p.add(low);
p.add(dingshi);
add(p,BorderLayout.SOUTH);
add.addActionListener(new ButtonHandler());
low.addActionListener(new ButtonHandler());
stop.addActionListener(new ButtonHandler());
dingshi.addActionListener(new ButtonHandler());
time_1=new Timer(1,x);
time_1.start();
}
class ButtonHandler implements ActionListener{
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==add){
if(time>=0)
time++;
else if(time<0)
time--;
}else if(e.getSource()==low){
if(time>0)
time--;
else if(time<0)
time++;
}else if(e.getSource()==stop){
if(time!=0){
ti=time;
time=0;}
else
time=ti;
}
else if(e.getSource()==dingshi){
if(time!=1){
ti=time;
time=1;}
else time++;
}
}
}
public static void main(String[] args){
jp=new TransPane();
Fan tran=new Fan();
tran.setSize(250,300);
tran.setVisible(true);
tran.pack();
}
public void actionPerformed(ActionEvent arg0) {
}
class x1 implements ActionListener{
public void actionPerformed(ActionEvent e){
TransPane t1=new TransPane();
jp.i+=time;
jp.repaint();
}
}
}
class TransPane extends JPanel{
int i=0;
protected void paintComponent(Graphics g){
super.paintComponent(g);
Graphics2D g2d=(Graphics2D) g;
int xCenter=getWidth()/2;
int yCenter=getHeight()/2;
int radius=(int)(Math.min(getWidth(),getHeight()*0.4));
int x=xCenter-radius;
int y=yCenter-radius;
AffineTransform trans=new AffineTransform();
g2d.fillArc(x,y,2*radius,2*radius,i,30); g2d.setColor(Color.red);
g2d.fillArc(x,y,2*radius,2*radius,i+60,30); g2d.setColor(Color.yellow);
g2d.fillArc(x,y,2*radius,2*radius,i+120,30); g2d.setColor(Color.green);
g2d.fillArc(x,y,2*radius,2*radius,i+180,30); g2d.setColor(Color.gray);
g2d.fillArc(x,y,2*radius,2*radius,i+240,30); g2d.setColor(Color.blue);
g2d.fillArc(x,y,2*radius,2*radius,i+300,30); g2d.setColor(Color.black);
}
⑹ JAVA_电风扇类,请教!
哪一行的作用是:
如果你的电风扇等级是 4级或以上则不输出 相当于做了一个判断回
我这里运行没有问题啊
美的牌电风扇答 Medi2000
The Fan is Starting.....started
The current speed is: 0
The current speed is: 1
The current speed is: 2
The current speed is: 3
The Fan is Stopping.....stopped
⑺ java课程设计
去网站上下载一个,这里没人能给你写这么多
⑻ Java定义一个表示风扇的类
publicclassTest{
publicstaticvoidmain(String[]args){
Fanfan1=newFan(25);
fan1.setOnoff(true);
System.out.println("fan1的半径是:"+fan1.getRadius()
+"fan1的状态是"+fan1.isOnoff());
Fanfan2=newFan(20,false);
System.out.println("fan2的半径是:"+fan2.getRadius()
+"fan2的状态是"+fan2.isOnoff());
}
}
classFan{
privatedoubleradius;
privatebooleanonoff;
publicFan(doubleradius){
this.radius=radius;
}
publicFan(doubleradius,booleanonoff){
this.radius=radius;
this.onoff=onoff;
}
publicdoublegetRadius(){
returnradius;
}
publicvoidsetRadius(doubleradius){
this.radius=radius;
}
publicbooleanisOnoff(){
returnonoff;
}
publicvoidsetOnoff(booleanonoff){
this.onoff=onoff;
}
}
⑼ 我要让这个java程序的风扇转起来,代码如下,不知道错在哪里了
你做题的套路我看的不是很清晰,在你的基础上我按照我自己的套路稍微改了下,能运行,不知是否有所帮助!
import java.util.Timer;
import java.awt.*;
import java.awt.event.*;
public class dingshi extends Frame{
static fengshan1 fengshan;
static Frame f;
public static void main(String[] args){
Frame f= new Frame();
Timer timer = new Timer();
fengshan=new fengshan1();
f.add(fengshan,BorderLayout.CENTER);
f.setSize(300,300);
f.setVisible(true);
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
timer.schele(new MyTask(), 1000, 50);//在1秒后执行此任务,每次间隔2秒,如果传递一个Data参数,就可以在某个固定的时间执行这个任务.
}
static class MyTask extends java.util.TimerTask
{
public void run(){
fengshan.i+=50;
fengshan.repaint();//重绘
}
}
}
class fengshan1 extends Panel
{
int i=0;
public void paint(Graphics g)
{
g.setColor(Color.red);
g.fillArc(100, 100, 100, 100, i, 30);
g.fillArc(100, 100, 100, 100, i+90, 30);
g.fillArc(100, 100, 100, 100, i+180, 30);
g.fillArc(100, 100, 100, 100, i+270, 30);
}
}