package com.itheima.test;
public class zuoye1 {
public static void main(String[] args) {
Phone P = new Phone("华为",2800);
P.setBrand("华为");
P.setPrice(2800);
P.call();
P.sendMessage();
P.playGame();
}
}
class Phone {
private String brand;
private int price;
public Phone() {
}
public Phone(String brand, int price) {
this.brand = brand;
this.price = price;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getBrand() {
return brand;
}
public void setPrice(int price) {
this.price = price;
}
public int getPrice() {
return price;
}
public void call() {
System.out.println("正在使用价格为" + price + "元的" + brand + "品牌的手机打电话...");
}
public void sendMessage() {
System.out.println("正在使用价格为" + price + "元的" + brand + "品牌的手机发信息...");
}
public void playGame() {
System.out.println("正在使用价格为" + price + "元的" + brand + "品牌的手机玩游戏...");
}
}
|
|