Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
1
10php
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yu Kimiduka
10php
Commits
5180c9a5
Commit
5180c9a5
authored
Jul 20, 2016
by
君塚 悠
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
プログラム作成(call.php,Figure.class.php,Square.class.php,Triangle.class.php:継承の学習)
parent
fcca232c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
89 additions
and
2 deletions
+89
-2
MyAuth.php
php/php10/day08_9/MyAuth.php
+1
-1
call.php
php/php10/day10-1/call.php
+1
-1
Figure.class.php
php/php10/day10-2/Figure.class.php
+37
-0
Square.class.php
php/php10/day10-2/Square.class.php
+12
-0
Triangle.class.php
php/php10/day10-2/Triangle.class.php
+12
-0
call.php
php/php10/day10-2/call.php
+26
-0
No files found.
php/php10/day08_9/MyAuth.php
View file @
5180c9a5
...
...
@@ -21,7 +21,7 @@ $param = array(
$auth
=
new
Auth
(
"DB"
,
$passwd
,
"MyLogin"
,
TRUE
);
$Auth
->
start
();
if
(
$auth
->
getUsername
()
==
""
)
{
//未承認→強制終了
//未承認→強制終了
する
exit
(
1
);
}
?>
\ No newline at end of file
php/php10/day10-1/call.php
View file @
5180c9a5
...
...
@@ -12,7 +12,7 @@ function __autoload($name)
require_once
(
$name
.
".class.php"
);
}
// Triangleクラスのインスタンス化
// Triangleクラス
(Triangle.class.phpに有る)
のインスタンス化
$objCls
=
new
Triangle
();
$objCls
->
set_width
(
10
);
$objCls
->
set_height
(
20
);
...
...
php/php10/day10-2/Figure.class.php
0 → 100644
View file @
5180c9a5
<?php
abstract
class
Figure
{
private
$width
;
private
$height
;
public
function
__construct
(){
$this
->
width
=
1
;
$this
->
height
=
1
;
}
public
function
__destruct
()
{
/*デストラクタ*/
}
public
final
function
get_width
()
{
return
$this
->
width
;
}
public
final
function
get_height
()
{
return
$this
->
height
;
}
public
final
function
set_width
()
{
if
(
is_numeric
(
$width
))
{
$this
->
height
=
$height
;
}
}
public
final
function
set_height
()
{
if
(
is_numeric
(
$height
))
{
$this
->
height
=
$height
;
}
}
//抽象メソッド
public
abstract
function
get_area
();
}
?>
php/php10/day10-2/Square.class.php
0 → 100644
View file @
5180c9a5
<?php
class
Square
extends
Figure
{
public
function
__construct
()
{
parent
::
__construct
();
}
public
function
get_area
()
{
return
$this
->
get_width
()
*
$this
->
get_height
();
}
}
\ No newline at end of file
php/php10/day10-2/Triangle.class.php
0 → 100644
View file @
5180c9a5
<?php
class
Triangle
extends
Figure
{
public
function
__construct
()
{
parent
::
__construct
();
}
public
function
get_area
()
{
return
$this
->
get_width
()
*
$this
->
get_height
/
2
;
}
}
php/php10/day10-2/call.php
0 → 100644
View file @
5180c9a5
<html>
<head>
<title>
オブジェクト指向入門(ポリモーフィズム)
</title>
</head>
<body>
<h1
style =
"background:#cccccc"
>
オブジェクト入門(ポリモーフィズム
</h1>
<?php
// autoload関数の定義
function
__autoload
(
$name
)
{
require_once
(
$name
.
".class.php"
);
}
// Triangleクラス(Triangle.class.phpに有る)のインスタンス化
$objTri
=
new
Triangle
();
$objTri
->
set_width
(
10
);
$objTri
->
set_height
(
20
);
print
(
"三角形の面積:"
.
$objTri
->
get_area
()
.
"<br>"
);
$objSqr
=
new
Square
();
$objSqr
->
set_width
(
10
);
$objSqr
->
set_height
(
20
);
print
(
"四角形の面積:"
.
$objSqr
->
get_area
()
.
"<br>"
);
?>
</body>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment