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);
}
}