1. 程式人生 > >java之Employee

java之Employee

() 高級程序員 AS uno AI print ID system oid

package learning;
import java.util.*;
import java.io.*;
public class Employee{
String name;
int age;
String designation;
double salary;
public Employee(String name) {
this.name = name;
}
public void empAge(int empAge) {
age = empAge;
}
public void empDesignation(String empDesig) {
designation = empDesig;
}
public void empSalary(double empSalary) {
salary = empSalary;
}
public void printEmployee() {
System.out.println("名字:"+ name);
System.out.println("年齡:"+ age);
System.out.println("職位:"+ designation);
System.out.println("薪水:"+ salary);
}
}

public class EmployeeTest {
public static void main(String args[]){
Employee empOne = new Employee("RUNOOB1");
Employee empTwo = new Employee("RUNOOB2");
empOne.empAge(26);
empOne.empDesignation("高級程序員");
empOne.empSalary(1000);
empOne.printEmployee();
empTwo.empAge(21);
empTwo.empDesignation("菜鳥程序員");
empTwo.empSalary(500);
empTwo.printEmployee();
}
}

java之Employee