Ex.01,Ex.02 完了

This commit is contained in:
2026-10-21 12:49:39 +09:00
parent 261ff5f68b
commit 9aebbab0ab
2 changed files with 38 additions and 1 deletions

View File

@@ -18,3 +18,18 @@
* 5. その後、showParameter() メソッドを呼び出して、キャラクター情報を出力してください。
*
*/
// 本ファイル内で、require_once を使い "/common/Hero.php" を読み込んでください。
require_once __DIR__ . '/common/Hero.php';
// namespace を利用して、inheritance\common\Common\Hero クラスを使用
// namespaceが書いてあれば呼び出し側はuseを使う必要がある
use inheritance\Common\Hero;
// Common\Hero クラスのインスタンスを生成し、
$hero = new Hero();
// setName() メソッドを使って名前に "勇者" を設定してください。
$hero->setName('勇者');
// showParameter() メソッドを呼び出して、キャラクター情報を出力
echo $hero->showParameter();