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. 各プロパティの値を、対応するゲッターを使って出力してください。
|
||||
*
|
||||
*
|
||||
*/
|
||||
43
Question12-Encapsulation/index.html
Normal file
43
Question12-Encapsulation/index.html
Normal file
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>PTra12スタートページ</title>
|
||||
|
||||
<!-- Bootstrap Core CSS -->
|
||||
<link href="../common/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="page-header">
|
||||
<h1>
|
||||
独習PHP第10章練習問題 <small>カプセル化</small>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="panel-group" id="accordion">
|
||||
<!-- ================== Ex01 ================== -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">
|
||||
<a href="Ex01.php" target="_blank">
|
||||
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
|
||||
PTra12_01</a> <small>カプセル化</small>
|
||||
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="../common/js/jquery-3.2.1.min.js"></script>
|
||||
|
||||
<!-- Bootstrap Core JavaScript -->
|
||||
<script src="../common/js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user