需要完整代码,谢谢
123456789055555555555(凑字数)
public class Computer {
private String brand;
private String model;
private int year;
private double price;
public Computer(String brand, String model, int year, double price) {
this.brand = brand;
this.model = model;
this.year = year;
this.price = price;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public void turnOn() {
System.out.println("The computer is turning on.");
}
public void turnOff() {
System.out.println("The computer is turning off.");
}
public void printSpecs() {
System.out.println("Brand: " + brand);
System.out.println("Model: " + model);
System.out.println("Year: " + year);
System.out.println("Price: $" + price);
}
public static void main(String[] args) {
Computer computer=new Computer("苹果电脑","16G内存",2023,12999);
computer.printSpecs();
}
}
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!