Files
java-question/Question13-Extends/src/PTra13_06.java
2026-09-09 08:34:32 +09:00

34 lines
1.3 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* PTra13_06.java
* 作成 Rhizome
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra13_06 {
/*
* TODO commonパッケージにHeroクラスを継承した、SuperHeroクラスを作成してから解いてください。
* ●HP, POWER, ENDURANCEはHeroと同じでそれぞれ、(25, 10, 7)
*
* フィールド
* Item item
* メソッド
* attackメソッドをオーバーライドし、
* powerフィールドの値に加えて、itemフィールドのadditionalDamage分を加算した値を返す
*
* itemフィールドのアクセサ
*/
public static void main(String[] args) {
// TODO SuperHeroインスタンスとSlimeインスタンスを作成し、それぞれの名前に"勇者(装備あり)", "スライム"を設定してください
// TODO Itemクラスのインスタンスを作成し、("こんぼう", 5)をコンストラクタの引数にしてください
// TODO SuperHeroインスタンスのitemフィールドに作成したitemインスタンスを設定してください
// TODO SuperHeroインスタンスのattackメソッドを呼び出して、戻り値を出力してください
// ※ 15と出力されれば正解
}
}