
int String 등은 생성자를 사용하지 않는다
선언하는 순간 정해진 메모리로 메모리가 할당되기 때문
객체의 경우 생성자를 사용해서 힙 메모리에 할당해야함
여러가지 생성자를 정의하는 것
디폴트 생성자와 매개변수를 직접 넣어서 생성하는 생성자를 모두 이용 가능
package ch8_practice;
public class Person {
	
	public String personName;
	public int personWeight;
	public int personHeight;
	public int personAge;
	public String personSex;
	
	public Person(String personName, int personWeight, int personHeight, int personAge, String personSex) {
		this.personName = personName;
		this.personWeight = personWeight;
		this.personHeight = personHeight;
		this.personAge = personAge;
		this.personSex = personSex;
		
	}
	
	public String showPersonInfo() {
		return "키가 " + personHeight + "이고 몸무게가 " + personWeight + "인 " + personSex + "이 있습니다. 이름은 " 
	+ personName + "이고 나이는 " + personAge + "입니다. ";
	}
}
package ch8_practice;
public class PersonTest {
	public static void main(String[] args) {
		
		Person personYoo = new Person("Yoo", 55, 170, 23, "여성");
		
		System.out.println(personYoo.showPersonInfo());
	}
}
package ch8_practice;
public class Order {
	
	public String orderNumber;
	public String orderPhoneNumber;
	public String orderAddress;
	public String orderDate;
	public String orderTime;
	public String orderPrice;
	public String orderMenu;
	
	public Order(String orderNumber, String orderPhoneNumber, String orderAddress, String orderDate, String orderTime, String orderPrice, String orderMenu) {
		this.orderNumber = orderNumber;
		this.orderPhoneNumber = orderPhoneNumber;
		this.orderAddress = orderAddress;
		this.orderDate = orderDate;
		this.orderTime = orderTime;
		this.orderPrice = orderPrice;
		this.orderMenu = orderMenu;
	}
	
	public String ShowOrderInfo() {
		return "주문 접수 번호 : " + orderNumber + "\n" +
				"주문 핸드폰 번호 : " + orderPhoneNumber + "\n" +
				"주문 집 주소 : " + orderAddress + "\n" +
				"주문 날짜 : " + orderDate + "\n" +
				"주문 시간 : " + orderTime + "\n" +
				"주문 가격 : " + orderPrice + "\n" +
				"메뉴 번호 : " + orderMenu + "\n" ;
	}
}
package ch8_practice;
import java.util.Scanner;
public class OrderTest{
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		System.out.println("주문 번호를 입력하세요");
		String orderNumber = scanner.next();
		System.out.println("주문 휴대폰 번호를 입력하세요");
		String orderPhoneNumber = scanner.next();
		System.out.println("주문 주소를 입력하세요");
		String orderAddress = scanner.next();
		System.out.println("주문 날짜를 입력하세요");
		String orderDate = scanner.next();
		System.out.println("주문 시간을 입력하세요");
		String orderTime = scanner.next();
		System.out.println("주문 가격을 입력하세요");
		String orderPrice = scanner.next();
		System.out.println("주문 메뉴 번호를 입력하세요");
		String orderMenu = scanner.next();
		
		Order order = new Order(orderNumber, orderPhoneNumber, orderAddress, orderDate, orderTime, orderPrice, orderMenu);
		
		System.out.println(order.ShowOrderInfo());	
	}
}