JAVA设计小作业(手机定义)
答案:1 悬赏:50 手机版
解决时间 2021-04-06 06:01
- 提问者网友:藍了天白赴美
- 2021-04-05 05:09
JAVA设计小作业(手机定义)
最佳答案
- 五星知识达人网友:天凉才是好个秋
- 2021-04-05 05:39
class Mobile {
private String bundle;
private String model;
private String color;
private int price;
public String getBundle() {
return bundle;
}
public void setBundle(String bundle) {
this.bundle = bundle;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public Mobile() {
super();
}
public Mobile(String bundle, String model, String color, int price) {
super();
this.bundle = bundle;
this.model = model;
this.color = color;
this.price = price;
}
public void showInfo() {
System.out.println("品牌:" + bundle + "
型号:" + model + "
颜色" + color
+ "
价格" + price);
}
}
public class TestMobile {
public static void main(String args[]) {
Mobile mobile = new Mobile("iphone", "6S", "gold", 4888);
mobile.showInfo();
}
}
private String bundle;
private String model;
private String color;
private int price;
public String getBundle() {
return bundle;
}
public void setBundle(String bundle) {
this.bundle = bundle;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public Mobile() {
super();
}
public Mobile(String bundle, String model, String color, int price) {
super();
this.bundle = bundle;
this.model = model;
this.color = color;
this.price = price;
}
public void showInfo() {
System.out.println("品牌:" + bundle + "
型号:" + model + "
颜色" + color
+ "
价格" + price);
}
}
public class TestMobile {
public static void main(String args[]) {
Mobile mobile = new Mobile("iphone", "6S", "gold", 4888);
mobile.showInfo();
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯