no message
This commit is contained in:
33
Question12-Encapsulation/Ex01.php
Normal file
33
Question12-Encapsulation/Ex01.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [Ex01 オブジェクト指向 - Studentクラスのアクセサの実装と制御処理の追加]
|
||||
*
|
||||
* TODO:
|
||||
* 1. 新しいファイル "Student.php" を作成し、以下の仕様に従って Student クラスを定義してください。
|
||||
* - クラス名: Student
|
||||
* - プロパティ(すべて private とする):
|
||||
* student_id, student_name, company_name, class_name, mail, password
|
||||
* - 各プロパティに対して、シンプルなゲッター(getXXX)とセッター(setXXX)を実装してください。
|
||||
* (例:getStudentId() と setStudentId($id) など)
|
||||
*
|
||||
* (下記は1,2,3,4の処理が終わった後の+αの課題です)
|
||||
* シンプルな実装ができたら、下記の特定のセッターに対して、追加の制御処理(バリデーション)を実装するようにしてください:
|
||||
* a. setStudentId($id) : $id が正の整数であることをチェックし、正しくない場合は 0 をセットする。
|
||||
* b. setMail($mail) : $mail が有効なメールアドレスの形式かチェックし、無効な場合は "unknown@example.com" をセットする。
|
||||
* c. setPassword($password) : $password の長さが8文字以上であるかチェックし、短い場合は "defaultPass" をセットする。
|
||||
*
|
||||
* 2. 本ファイル内で、require_once を使い "Student.php" を読み込んでください。
|
||||
*
|
||||
* 3. Student クラスのインスタンスを生成し、以下の値を各セッターで設定してください。
|
||||
* - student_id: 10001
|
||||
* - student_name: "リゾーム太郎"
|
||||
* - company_name: "株式会社リゾーム"
|
||||
* - class_name: "Z教室"
|
||||
* - mail: "rhizome@hogehoge.com"
|
||||
* - password: "1qazxcvb"
|
||||
*
|
||||
* 4. 各プロパティの値を、対応するゲッターを使って出力してください。
|
||||
*
|
||||
*
|
||||
*/
|
||||
Reference in New Issue
Block a user