面向对象的哲学。举例:小明被撞了,智商一百早上好。智商不好,乱说
2017-03-14 20:48
148 查看
<?php header("Content-Type:text/html;charset=utf-8"); class People{ public $iq = 100; public function Sayhello(){//打招呼 $say = array("good morning","good noon","good evening"); if($this->iq >= 100){//智商大于等于100 goodmorning echo $say[0]; }else{ $i = rand(0,2);//随机 echo $say[$i]; } } } class Car{ public function Hitme($people){ //撞了下 $iqs = rand(50,110);//智商随你在50-100. $people -> iq = $iqs;//赋给传过来的人!!! } } $ming = new People();//生成人 $BMW = new Car();//生成汽车 $BMW -> Hitme($ming);//宝马撞了小明 $ming -> sayhello(); $BMW -> Hitme($ming); $ming -> sayhello(); $BMW -> Hitme($ming); $ming -> sayhello();
相关文章推荐
- 面向对象的哲学。举例:小明被撞了,智商一百早上好。智商不好,乱说
- 面向对象的哲学。举例:小明被撞了,智商一百早上好。智商不好,乱说
- 面向对象的哲学。举例:小明被撞了,智商一百早上好。智商不好,乱说
- 面向对象的哲学。举例:小明被撞了,智商一百早上好。智商不好,乱说
- 面向对象的哲学。举例:小明被撞了,智商一百早上好。智商不好,乱说
- 面向对象的哲学。举例:小明被撞了,智商一百早上好。智商不好,乱说
- 面向对象的哲学。举例:小明被撞了,智商一百早上好。智商不好,乱说
- 面向对象的哲学。举例:小明被撞了,智商一百早上好。智商不好,乱说
- 面向对象的哲学。举例:小明被撞了,智商一百早上好。智商不好,乱说
- 面向对象的哲学。举例:小明被撞了,智商一百早上好。智商不好,乱说
- 黑马程序员——Objective-C面向对象self和super关键词的用法笔记和举例
- 面向对象与哲学
- 面向对象(举例)
- PHP面向对象笔记 —— 107 面向对象的哲学
- python-面向对象(股票对象举例)
- 面向对象与哲学
- OO真经——关于面向对象的哲学体系及科学体系的探讨
- 如何通俗易懂地举例说明“面向对象”和“面向过程”有什么区别?
- 不要总埋怨自己记忆不好了,其实跟你的智商关系不大
- OO真经——关于面向对象的哲学体系及科学体系的探讨(上)