วันอังคารที่ 25 พฤศจิกายน พ.ศ. 2557

Lab.5 Class employee

class Employee {
  String name;
  int age;
  String position;
  float salary;
  String address;
  Employee(String name) {
    this.name = name;
  }
  void age(int Age) {
    this.age =  Age;
  }
  void position(String Position) {
    this.position = Position;
  }
  void salary(float Salary) {
    this.salary = Salary;
  }
  void address(String Address) {
    this.address = Address;
  }
  void printEmp_data() {
    println("Name     : " + this.name );
    println("Age      : " + this.age );
    println("Position : " + this.position);
    println("Address  : " + this.address);
    println("Salary   : " + this.salary + " Baht");
  }
 
}

void setup() {

  Employee number1 = new Employee ("B");
  number1.age(25);
  number1.position("Engineer");
  number1.address("");
  number1.salary(20000);
  number1.printEmp_data();
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น