package Exam;

import java.util.Scanner;

//부모 클래스
class Instrument {
 String name;
 String type;

 // 기본 생성자
 Instrument() {
     this.name = "이름 없음";
     this.type = "종류 없음";
 }

 // 매개변수가 있는 생성자
 Instrument(String name, String type) {
     this.name = name;
     this.type = type;
 }

 // 정보 출력 메서드
 void printInfo() {
     System.out.println("악기 이름: " + name);
     System.out.println("악기 종류: " + type);
 }
}

//자식 클래스
class Guitar extends Instrument {
 int stringCount;

 // 기본 생성자
 Guitar() {
     super();  // 부모 기본 생성자 호출
     this.stringCount = 0;
 }

 // 매개변수가 있는 생성자
 Guitar(String name, String type, int stringCount) {
     super(name, type);  // 부모 생성자 호출
     this.stringCount = stringCount;
 }

 // 메서드 오버라이딩
 @Override
 void printInfo() {
     super.printInfo(); // 부모의 정보 출력
     System.out.println("줄 개수: " + stringCount + "줄");
 }
}

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

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

     System.out.print("악기 종류 입력: ");
     String type = sc.nextLine();

     System.out.print("줄 개수 입력: ");
     int strings = sc.nextInt();

     System.out.println("------------------------------");
     System.out.println("입력한 기타 정보입니다!");

     Guitar guitar = new Guitar(name, type, strings);
     guitar.printInfo();

     sc.close();
 }
}
