package Exam;

import java.util.Scanner;

//부모 클래스
class Plant {
 String name;
 int growthTime;

 // 생성자
 Plant(String name, int growthTime) {
     System.out.println("[Plant 생성자 호출]");
     this.name = name;
     this.growthTime = growthTime;
 }

 // final 메서드 (오버라이딩 불가)
 public final void printInfo() {
     System.out.println("식물 이름: " + name);
     System.out.println("성장 시간: " + growthTime + "일");
 }
}

//자식 클래스
class Flower extends Plant {
 String color;

 // 생성자
 Flower(String name, int growthTime, String color) {
     super(name, growthTime); // 부모 생성자 호출
     System.out.println("[Flower 생성자 호출]");
     this.color = color;
 }

 // 부모의 final 메서드는 오버라이딩 불가 → super.printInfo()를 호출하여 활용
 void printFlowerInfo() {
     super.printInfo(); // 부모 정보 출력
     System.out.println("꽃 색깔: " + color);
 }
}

//실행 클래스
public class C6_Pro04_Main {
 public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);

     System.out.print("식물 이름 입력: ");
     String name = sc.nextLine();

     System.out.print("성장 시간(일) 입력: ");
     int growthTime = sc.nextInt();
     sc.nextLine(); // 개행 제거

     System.out.print("꽃 색깔 입력: ");
     String color = sc.nextLine();

     Flower flower = new Flower(name, growthTime, color);

     System.out.println("--------------------------");
     flower.printFlowerInfo();

     sc.close();
 }
}
