Code
public class Member {
String id;
String pwd;
String name;
String personalNo;
Integer status;
void setId (String id){
if(id.length()<6) {
System.out.println("아이디가 6자 미만입니다.");
}
else {this.id = id;}
}
void setPwd (String pwd){
if(pwd.length()<6) {
System.out.println("비밀번호가 6자 미만입니다.");
}
else {this.pwd = pwd;}
}
void setPersonalNo (String personalNo) {
if (personalNo.length() != 14) {
System.out.println("잘못된 주민등록 번호입니다.");
}
else {
this.personalNo = personalNo;
}
}
// 주민등록번호를 통해 나이를 계산하는 메서드
void getAge() {
if (personalNo != null) {
String [] split = personalNo.split("-");
Integer gen = Integer.parseInt(split[1].substring(0, 1));
String birth = "";
if(gen >= 3){
birth = "20" + split[0];
}
else {
birth = "19"+split[0];
}
System.out.println(2022-Integer.parseInt(birth.substring(0, 4)));
System.out.println(Integer.parseInt(birth.substring(0, 4)) <= 2003);
}
}
}