?? computer.java
字號:
package myPackage;
import java.io.*;
public class Computer{
//定義屬性:品牌,顏色,CPU,內存,硬盤,價格,狀態
private String brand;
private String color;
private String CPU;
private String RAM;
private String HDisk;
private float price;
private boolean state1=true ; //true為打開狀態
private boolean state2=true ; //true為掛起狀態
public Computer( ){ //定義缺省值的構造方法
brand="HEDY";
color="white";
CPU="AMD";
RAM="KingMax";
HDisk="WD";
price=3999;
}
public Computer(String brand,String color,String CPU,String RAM,String HDisk,float price){
this.brand=brand; //定義具有指定值的構造方法
this.color=color;
this.CPU=CPU;
this.RAM=RAM;
this.HDisk=HDisk;
this.price=price ;
}
public void display() { //輸出品牌,顏色,CPU,內存,硬盤,價格
System. out .println("品牌: "+brand);
System. out .println("顏色: "+color);
System. out .println("CPU : "+CPU);
System. out .println("內存: "+RAM);
System. out .println("硬盤: "+HDisk);
System. out .println("價格: "+price+"元");
}
public void ComStateOn( ){ //控制計算機的打開與關閉
if(state1) {
state1=false;
System.out.println("The computer is shutdowned!!!");
}
else {
state1=true;
System.out.println("The computer is starting!!!");
}
}
public void ComStateWaken( ){ //控制計算機的掛起與恢復
if( state2){
state2=false;
System.out.println("The computer is sleeping!!!");
}
else {
state2=true;
System.out.println("The computer is awake!!!");
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -