# 메소드 오버라이딩
## 문제
주어진 뼈대코드는 초보자(Novice) 클래스를 확장하여 마법사(Wizard) 클래스를 정의하고 있다. toString() 메소드를 "오버라이딩"하여 아래와 같은 실행결과를 얻으시오.
```
[Novice] 초보(HP: 100)
[Wizard] 해리포터(HP: 100, MP: 100)
```
## 메소드 오버라이딩이란?
부모의 메소드를 자식에서 재정의 하는 것.
## 뼈대코드
```
public class Main {
public static void main(String[] args) {
// 객체 생성
Novice chobo = new Novice("초보", 100);
Wizard wizard = new Wizard("해리포터", 100, 100);
// 객체 정보 출력
System.out.println(chobo.toString());
System.out.println(wizard.toString());
}
}
class Novice {
// 필드
protected String name;
protected int hp;
// 생성자
public Novice(String name, int hp) {
this.name = name;
this.hp = hp;
}
// toString
public String toString() {
return String.format("[Novice] %s(HP: %d)", this.name, this.hp);
}
}
class Wizard extends Novice {
// 필드
protected int mp;
// 생성자
public Wizard(String name, int hp, int mp) {
super(name, hp);
this.mp = mp;
}
/* toString() 메소드를 오버라이딩 하시오. */
}
```