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

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 15863453752 中级黑马   /  2015-8-29 22:10  /  422 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

class DemoEmployee {
        public static void main(String[] args) {
                Employee e1 =new Employee();
                e1.setName("张三");
                e1.setId(100100);
                e1.setSalary(18000);
                System.out.println("姓名:"+e1.getName()+",卡号:"+e1.getId()+",薪水:"+e1.getSalary());

                Employee e2 = new Employee("李四",100220,19000);
            e2.work();
        }
}

class Employee {
        private String name;
        private int id;
        private int salary;

        public Employee() {
       
        }

        public Employee(String name,int 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(int id) {
                this.id = id;
        }

        public int getId() {
                return id;
        }

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

        public int getSalary() {
                return salary;
        }

        public void work() {
                System.out.println(name + "..."+id+"..."+salary);
        }
}

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马