計算機屬性 其中組成部分有CPU 硬盤 內存

CUP性能

package week;測試

public interface CPU {this

public String brand(String brand);
public String frequence(String brand);
}blog

硬盤內存

package week;ci

public interface HardDisk {it

public String capacityY(String capacity);class

}im

內存static

package week;

public interface Memory {

public String capacityN(String capacity);

}

計算機性能

package week;

public class Computer implements CPU,HardDisk,Memory{

String brand;
public String brand(String brand) {
this.brand = brand;
return brand;
}

String frequence;
public String frequence(String frequence) {
this.frequence = frequence;
return frequence;
}

String capacity1;
public String capacityY(String capacity) {
this.capacity1 = capacity;
return capacity;
}

String capacity2;
public String capacityN(String capacity) {
this.capacity2 = capacity;
return capacity;
}

public void printer(){
System.out.println("計算機的信息以下:");
System.out.println("CPU的品牌是:"+brand+"主頻爲:"+frequence);
System.out.println("硬盤容量是:"+capacity1);
System.out.println("內存容量是:"+capacity2);
}

}

測試類

package week;

public class Test {
public static void main(String[] args) {
Computer computer = new Computer();
computer.brand("Inter");
computer.frequence("3.8GHz");
computer.capacityY("3000GB");
computer.capacityN("8GB");
computer.printer();
}
}

測試結果

相關文章
相關標籤/搜索