package com.mg.java.day05;
public class MobilePhone {
String brand;
int price;
String generation;
public void sendMsg(String name) {
System.out.println(name + "晚上一起吃饭吗?");
System.out.println("来自" + this.brand + this.generation + "价格" + this.price);
}
// 无参构造函数
public MobilePhone() {
}
// 有参构造函数
public MobilePhone(String brand, int price, String generation) {
this.brand = brand;
this.price = price;
this.generation = generation;
}
public static void main(String[] args) {
MobilePhone mobilePhone = new MobilePhone();
String name = "小华";
mobilePhone.sendMsg(name);
MobilePhone mobilePhone2 = new MobilePhone("苹果", 8888, "8P");
mobilePhone2.sendMsg("小明");
}
}