JAVA 복습하기

서화진·2022년 8월 17일
0

JAVA 학습일지

목록 보기
5/13

1) TEST!! 객체 구현하기 2

package test01;

public class PersonInfo {
	
	public String height;
	public String weight;
	public String personName;
	public String personAge;
	public String personSex;
	
	public PersonInfo() {}
		
	public PersonInfo(String height, String weight, String personName, String personAge, String personSex) {
		
		this.height = height;
		this.weight = weight;
		this.personName = personName;
		this.personAge = personAge;
		this.personSex = personSex;
	}
	
	public String showpersonInfo() {
		
		return "키가 " + height + "이고, 몸무게가 " + weight + "킬로인 " + personSex + " 이 있습니다. 이름은 "+ personName  + " 이고, 나이는 " + personAge + "세 입니다.";
				
	}
	
	
	}

package test01;

public class PersonInfoTest {

	public static void main(String[] args) {

		
		PersonInfo Tomas = new PersonInfo();
			
			Tomas.height = "180";
			Tomas.weight = "78";
			Tomas.personSex = "남성";
			Tomas.personName = "Tomas";
			Tomas.personAge = "37";
			
			System.out.println(Tomas.showpersonInfo());
			
			}
	
		
	}

2) 출력

키가 180이고, 몸무게가 78킬로인 남성 이 있습니다. 이름은 Tomas 이고, 나이는 37세 입니다.


아직도 따라치기 바쁜 왕--초보지만 따라치는것도 제법 재밌다 ㅎ.ㅎ

언젠가는 앞에 한거 참고안하고 타다다다 코딩하는 날이 오겠지!

profile
초보 개발자 / 학습일지 : https://velog.io/@dinyyyyy

0개의 댓글