A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 小b,试试就试试 中级黑马   /  2016-7-30 22:43  /  438 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

根据需求,完成如下代码(按照标准格式写),并在测试类中进行测试。
        需求一:
                项目经理类
                        属性:姓名 工号 工资 奖金
                        行为:工作work
                程序员类
                        属性:姓名 工号 工资
                        行为:工作work



class Text1 {
        public static void main(String[] args) {
                Jing j = new Jing("张三","007",18000,20000);
                j.show();
                Yuan y = new Yuan("李四","008",20000);
                y.show();
        }
}

class Employee{

        private String name;
        private String id;
        private int salary;
       
        public Employee(){}

        public Employee(String name,String id,int salary){
        this.name = name;
        this.id = id;
        this.salary =salary;
        }

        public void setName(String name){
        this.name = name;
        }

        public String getName(){
                return name;
        }

       
        public void setId(String id){
        this.id = id;
        }

        public String getId(){
                return id;
        }

       
        public void setSalary(int salary){
        this.salary = salary;
        }

        public int getSalary(){
                return salary;
        }

        public void work(){
        System.out.println("工作");
        }
}


class Jing extends Employee{
        private int money;

        public Jing(){}

        public Jing(String name,String id,int salary,int money){
        super(name,id,salary);
        this.money = money;
        }

        public void show(){
        System.out.println(getName()+"  "+getId()+"  "+getSalary()+"  "+money);
        }

}

class Yuan extends Employee{

        public Yuan(){}

        public Yuan(String name,String id,int salary){
        super(name,id,salary);
        }
        public void show(){
        System.out.println(getName()+"  "+getId()+"  "+getSalary());
        }

}

1 个回复

倒序浏览
我只是搬运工,不要问我为什么
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马