黑马程序员技术交流社区

标题: //// [打印本页]

作者: 潘弘非    时间: 2020-3-2 19:03
标题: ////
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 + "品牌的手机玩游戏...");
        }
    }





欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2