public class Car {
    private String brand;
    private double power;
    public Car(){
    }
    public Car(String brand,double power){
        this.brand=brand;
        this.power=power;
        System.out.println(brand+"-"+power);
    }
    public void warning(){
        if (power<10){
            System.out.println("电量不足");
        }else {
            System.out.println("电量充足");
        }
    }
    public String getBrand() {
        return brand;
    }
    public void setBrand(String brand) {
        this.brand = brand;
    }
    public double getPower() {
        return power;
    }
    public void setPower(double power) {
        this.power = power;
    }
}
public class Test {
    public static void main(String[] args) {
        Car car=new Car("特斯拉",50);
        car.warning();
        Car car1=new Car("比亚迪",9);
        car1.warning();
    }
}
		
3. 1.项目经理类Manager 
		属性:
			姓名name
			工号id
			工资salary
			奖金bonus
		行为:
			工作work()
	2.程序员类Coder
		属性:
			姓名name
			工号id
			工资salary
		行为:
			工作work()
	
public class Manager {
    private String name;
    private int id;
    private double salary;
    private double bonus;
    public Manager(){
    }
    public Manager(String name,int id,double salary,double bonus){
        this.name=name;
        this.id=id;
        this.salary=salary;
        this.bonus=bonus;
    }
    public void work(){
        System.out.println("工号为"+id+"基本工资为"+salary+"奖金为"+bonus+"的项目经理"+name+"正在努力的做着管理工作,分配任务,检查员工提交上来的代码.....");
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public double getSalary() {
        return salary;
    }
    public void setSalary(double salary) {
        this.salary = salary;
    }
    public double getBonus() {
        return bonus;
    }
    public void setBonus(double bonus) {
        this.bonus = bonus;
    }
}
public class Coder {
    private String name;
    private int id;
    private double salary;
    public Coder(){
    }
    public Coder(String name, int id, double salary){
        this.name=name;
        this.id=id;
        this.salary=salary;
    }
    public void work(){
        System.out.println("工号为"+id+"基本工资为"+salary+"的程序员"+name+"正在努力的写着代码......");
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public double getSalary() {
        return salary;
    }
    public void setSalary(double salary) {
        this.salary = salary;
    }
}
public class Test {
    public static void main(String[] args) {
        Manager manager=new Manager("周扒皮",123,15000,6000);
        manager.work();
        Coder coder=new Coder("杨白劳",135,10000);
        coder.work();
    }
}

  

public class Phone { private String brand; private double price; public Phone(){ } public Phone(String brand,double price){ this.brand=brand; this.price=price; System.out.println("品牌:"+brand+",价格:"+price); } public void call(){ System.out.println("正在使用价格为"+price+"元的手机打电话...."); } public void sendMessage(){ System.out.println("正在使用"+brand+"品牌的手机发短信...."); } public void playGame(){ System.out.println("正在使用价格为"+price+"元的小米品牌的手机玩游戏...."); } public String getBrand() { return brand; } public void setBrand(String brand) { this.brand = brand; } public double getPrice() { return price; } public void setPrice(double price) { this.price = price; } } public class Test { public static void main(String[] args) { Phone phone=new Phone("小米",998); //Phone phone=new Phone(); //phone.setBrand("小米"); //phone.setPrice(998); phone.call(); phone.sendMessage(); phone.playGame(); } }