Files
2026-10-06 12:10:09 +09:00

28 lines
1.1 KiB
PHP
Raw Permalink 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.

<?php
/**
* [Ex05 オブジェクト指向 - Itemクラスの作成と利用]
*
* 難易度:初級
*
* TODO:
* 1. 新しいファイル "common/Item.php" を作成し、以下の仕様に従って Item クラスを定義してください。
* - クラス名: Item
* - プロパティ(すべて private):
* - name : string
* - additional_damage : int
* - 各プロパティのゲッターとセッターを実装してください。
* - コンストラクタ: 引数として name と additional_damage を受け取り、各プロパティに初期値を設定する。
*
* 2. 本ファイル内で、require_once を使い "common/Item.php" を読み込んでください。
*
* 3. namespace を利用して、Common\Item クラスを使用してください。
*
* 4. 以下の仮のデータを利用して、Common\Item クラスのインスタンスを生成してください:
* - name: "Sword"
* - additional_damage: 15
*
* 5. 生成した Item インスタンスの各プロパティの値を、アクセサ(ゲッター)を利用して出力してください。
*
*/