黑马程序员技术交流社区
标题:
【成都校区】开学第一天
[打印本页]
作者:
人生漫漫、
时间:
2019-9-18 19:19
标题:
【成都校区】开学第一天
public class Phone {
private String brand;
private String price;
private static int size;
public void show(){
System.out.println(brand+" "+ price+"元 "+size+"寸");
}
public Phone(String brand, String price) {
this.brand = brand;
this.price = price;
}
public Phone() {
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public static int getSize() {
return size;
}
public static void setSize(int size) {
Phone.size = size;
}
public void call(){
System.out.println("打电话");
}
public void sendMessage(){
System.out.println("发短信");
}
public void playGame(){
System.out.println("玩游戏");
}
}
[code]public class Dome {
public static void main(String[] args) {
Phone.setSize(6);
Phone a = new Phone("小米","3999");
Phone b = new Phone("华为","4999");
a.show();
b.show();
}
}
复制代码
[/code]
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2