Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- github
- 페이지 재사용
- 인코딩
- 관리자회원조회
- jdbc설정
- 비밀번호암호화
- 내배카
- jsp기본
- 입력메소드
- emmet환경설정
- mvc
- 로그아웃
- 정처기
- 국취제
- live server 환경설정
- forward
- Git
- 회원정보수정
- 검색기능
- 별찍기
- 국민취업지원제도
- 국비학원
- 배열
- 권한변경
- 회원탈퇴
- jdbc환경설정
- 내일배움카드
- 페이징
- 비밀번호변경
- redirect
Archives
- Today
- Total
기록
*14일차 실습 본문
[문제]
캡슐화를 적용하여 value object class를 작성하고 생성자를 통해 객체를 생성하여 초기화하여 출력
package com.oop.employee.model.vo;
public class Employee {
public Employee() {};
private int empNo;
private String name;
private char gender;
private String phone;
private String dept;
private int salary;
private double bonusPct;
public Employee(int empNo, String name,char gender,String phone) {
this.empNo = empNo;
this.name=name;
this.gender=gender;
this.phone=phone;
}
public Employee(int empNo, String name,char gender,String phone,String dept,int salary,double bonusPct)
{
this(empNo,name,gender,phone);
this.dept=dept;
this.salary=salary;
this.bonusPct=bonusPct;
}
public void printEmployee() {
System.out.printf("%d , %s , %c , %s , %s , %d, %.2f",
empNo,name,gender,phone,dept,salary,bonusPct);
}
public void setempNo(int empNo) {
this.empNo=empNo;
}
public int getempNo() {
return empNo;
}
public void setName(String name) {
this.name=name;
}
public String getName() {
return name;
}
public void setGender(char gender) {
this.gender=gender;
}
public char getGender() {
return gender;
}
public void setPhone(String phone) {
this.phone=phone;
}
public String getPhone() {
return phone;
}
public void setDept(String dept) {
this.dept=dept;
}
public String getDept() {
return dept;
}
public void setSalary(int salary) {
this.salary=salary;
}
public int getSalary() {
return salary;
}
public void setBonusPct(double bonusPct) {
this.bonusPct=bonusPct;
}
public double getBonusPct() {
return bonusPct;
}
}
package com.oop.employee.controller;
import com.oop.employee.model.vo.Employee;
public class Run {
public static void main(String[] args) {
Employee emp = new Employee();
Employee emp2 = new Employee(1,"홍길동",'남',"010-7777-7777");
Employee emp3 = new Employee(2,"유관순",'여',"010-3131-3131","영업부"
,3000000,0.15);
emp.printEmployee();
System.out.println();
emp2.printEmployee();
System.out.println();
emp3.printEmployee();
}
}