JAVA編程練習(xí)創(chuàng)建風(fēng)扇對象(開關(guān)風(fēng)速等)

自帶測試類
源代碼:

在新城等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站建設(shè)、網(wǎng)站制作 網(wǎng)站設(shè)計制作定制網(wǎng)站制作,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),全網(wǎng)營銷推廣,外貿(mào)網(wǎng)站制作,新城網(wǎng)站建設(shè)費(fèi)用合理。

public class TestFan {
    public static void main(String[] args) {
    Fan o1=new Fan();
    Fan o2=new Fan();
    o1.setspeed(o1.FAST);
    o1.setradius(10);
    o1.setcolor("yellow");
    o1.seton(true);
    o2.setspeed(o1.MEDIUM);
    o2.setradius(5);
    o2.setcolor("blue");
    o2.seton(false);
    System.out.println(o1.toString());
    System.out.println(o2.toString());
    } 
}

class Fan{
int SLOW=1,MEDIUM=2,FAST=3;
private int speed=SLOW;
private boolean on=false;
private double radius=5;
String color="blue";
public Fan(){
}
public void setspeed(int newspeed){
speed=newspeed;
}
public void seton(boolean newon){
on=newon;
}
public void setradius(double newradius){
radius=newradius;
}
public void setcolor(String newcolor){
color=newcolor;
}
public int getspeed(){
return speed;
}
public boolean geton(){
return on;
}
public double getradius(){
return radius;
}
public String getcolor(){
return color;
}
public String toString(){
if(on){
return speed+" "+color+" "+radius;
}
else{
return "fan is off";
}
}
}

運(yùn)行結(jié)果:
JAVA編程練習(xí)  創(chuàng)建風(fēng)扇對象(開關(guān) 風(fēng)速等)

網(wǎng)頁名稱:JAVA編程練習(xí)創(chuàng)建風(fēng)扇對象(開關(guān)風(fēng)速等)
分享地址:http://bm7419.com/article40/jddjeo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)、面包屑導(dǎo)航云服務(wù)器、響應(yīng)式網(wǎng)站、搜索引擎優(yōu)化、網(wǎng)站營銷

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)