Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
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
more
Archives
Today
Total
관리 메뉴

WON.dev

chapter06 : Local / LocalMain 본문

JAVA/chapter15_access_modifer

chapter06 : Local / LocalMain

GAWON 2023. 5. 26. 18:47
package org.joonzis.ex;
public class Ex06_Local {

	private String name;		
	private int age;			
	private String sn;			
	private boolean isKorean;	
		
	public Ex06_Local(String name, int age) {
		this(name, age, null);
	}
	public Ex06_Local(String name, int age, String sn){
		this.name = name;
		this.age = age;
		this.sn   = sn;
		if(sn != null) {
			this.isKorean = sn.charAt(7) <= '4' ? true : false;
		}else {
			this.isKorean = false;
		}
	}
				
	public void output() {
			System.out.println("이름 : " + name);
			System.out.println("나이 : " + age);
			System.out.println("주민등록 번호 : " + (sn == null ? "없음" : sn));
			System.out.println(isKorean ? "한국인" : "외국인"); 
	}
	
}
package org.joonzis.ex;

public class Ex06_LocalMain {

	public static void main(String[] args) {
		
		Ex06_Local person1 = new Ex06_Local("김김김", 30, "999999-1234567");
		Ex06_Local person2 = new Ex06_Local("박박박", 25, "888888-5678912");
		Ex06_Local person3 = new Ex06_Local("돼지왕", 20);
		
		person1.output();
		System.out.println("---------------------------");
		person2.output();
		System.out.println("---------------------------");
		person3.output();

	}

}

'JAVA > chapter15_access_modifer' 카테고리의 다른 글

chapter07 : Triangle / TriangleMain  (0) 2023.05.26
chapter05 : Circle / CircleMain  (0) 2023.05.26
chapter04 : Book / BookMain  (0) 2023.05.26
chapter03 : person / personmain  (0) 2023.05.26
chapter02 : Student / StudentMain  (0) 2023.05.26