小伙伴们一起加油哈
- class Test2_Employee {
- public static void main(String[] args) {
- Employee ee = new Employee("星爷","零零发",2000000);
- ee.work();
- }
- }
- class Employee {
- private String name;
- private String id;
- private double salary;
- //构造方法
- public Employee() {}
- public Employee(String name,String id, double 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(double salary) {
- this.salary = salary;
- }
- public double getSalary() {
- return salary;
- }
- //work方法,打印所有成员变量信息.
- public void work() {
- System.out.println("我的姓名是" + name + ",我的工号是" + id + ",我的工资是" + salary +"每天都要敲代码");
- }
- }
复制代码 |
|