클래슀

νŒ¨ν‚€μ§€ : μžλ°” μ½”λ“œκ°€ μœ„μΉ˜ν•  디렉토리

λ¦¬νŒ©ν† λ§ : 기쑴의 κΈ°λŠ₯을 κ·ΈλŒ€λ‘œ 두고 μ½”λ“œμ˜ 가독성을 λ†’μ΄κ±°λ‚˜ λ©”μ„œλ“œλ₯Ό μ΄λ™μ‹œν‚€λŠ” 것

클래슀 : 데이터와 λ©”μ„œλ“œκ°€ ν•˜λ‚˜μ˜ λͺ¨λ“ˆλ‘œ κ΅¬μ„±λ˜μ–΄ μžˆλŠ” κ²ƒμœΌλ‘œ μž¬μ‚¬μš©ν•˜κΈ° νŽΈν•˜κ²Œ λͺ¨λ“ˆμ„ 제곡

정보은닉 : μ •λ³΄λ³΄μ•ˆμ΄ μ•„λ‹Œ μ˜λ„μΉ˜ μ•Šμ€ μ½”λ“œ κ΅¬ν˜„μ„ μœ„ν•΄ λ‹€λ₯Έ κ°œλ°œμžμ—κ²Œ 감좔기 μœ„ν•œ 것

κ²Œν„° λ˜λŠ” μ„Έν„°λ§Œ μ‘΄μž¬ν•΄μ•Όν•œλ‹€. λ‘˜ λ‹€ μžˆλ”°λ©΄ public으둜 μ„€μ •ν•˜λŠ” 것이 μ˜¬λ°”λ₯΄λ‹€.

μ˜μ‘΄μ„± μ£Όμž…

Emp ν΄λž˜μŠ€κ°€ Dpt 의 κΈ°λŠ₯을 μ‚¬μš©ν•œλ‹€ == μ˜μ‘΄ν•œλ‹€.

// μƒˆλ‘œ μƒμ„±μ‹œ λ„€ 개의 κ°’ 전달

public Emp(String employeeId, String employeeName, int totalYearsOfService, String departmentCode) {
	this.employeeId = employeeId;
	
	this.employeeName = employeeName;
	
	this.totalYearsOfService = totalYearsOfService;
	
	this.departmentCode = departmentCode;

}

Label ν”„λ‘œκ·Έλž¨ μ½”λ“œ 이해λ₯Ό μ‰½κ²Œ ν•  수 있게 ν•΄μ€€λ‹€.

FIND: for (var emp : empList) {

	String employeeId = emp.getEmployeeId();
	
	if ("E004".equals(employeeId)) {
	
		findEmp = emp.propfile();
		
		break FIND;

	}

}

μ€‘λ³΅λœ 데이터 생성

public class Dpt {

// λΆ€μˆ˜ 정보λ₯Ό ν‚€λ‘œ μž…λ ₯ λ°›μ•„ ν…Œμ΄λΈ”μ— μ €μž₯ 및 νŠΉμ • ν‚€ κ°€μ Έμ˜¬ 수 μžˆλ„λ‘ ν•˜λŠ” μ½”λ“œ

private static HashMap<String, String> dptData = new HashMap<> (); // Field μ˜μ—­ λ©€λ²„λ³€μˆ˜no

public Dpt() {
	init();
}

public void init() {

dptData.put("D01", "개발1νŒ€");

dptData.put("D02", "νšŒκ³„");

dptData.put("D03", "사μž₯");

}

  

public String getDepartmentName(String departmentCode) {

return dptData.get(departmentCode);

}

  

}

문제 : 데이터가 계속 μ€‘λ³΅μœΌλ‘œ μž…λ ₯λœλ‹€.