摘要: 面向过程解决";}hanio(2, 'A', 'B', 'C');?> 面向过程写n = $n; $this->start = $start; $this->mediator = $mediator; $this->goal = $goal; } //单个盘移动 private funct... 阅读全文
posted @ 2014-11-21 15:32 tai君 阅读(672) 评论(0) 推荐(0) 编辑
摘要: php实现的八皇后问题,可以推广到N皇后m = $m; $this->put(0); } //判断第$n行放置位置$queen[$n] = $i 是否和前面的行冲突(同行,同列冲突,对角线冲突) /** * @param $n 第n行 * @return bool是否冲突 */ pri... 阅读全文
posted @ 2014-11-21 14:33 tai君 阅读(854) 评论(0) 推荐(0) 编辑
摘要: 代码片段一:contact[] = $tel; } public function delTel($tel){ $key = array_search($tel, $this->contact); if($key !== FALSE){ unset($this->contact[$key]... 阅读全文
posted @ 2014-11-19 14:52 tai君 阅读(230) 评论(0) 推荐(0) 编辑
摘要: name.' '; echo $this->price.'元'; }}//生成对象。$coffee = new coffee();//$coffee->showprice();//上面我已经生成了一个对象,现在已经在线上运行//但是我想动态的为coffee对象添加功能,而不改变原有的类和继承关... 阅读全文
posted @ 2014-11-17 12:04 tai君 阅读(162) 评论(0) 推荐(0) 编辑
摘要: flat();//以上是已经存在的对象小明,他在中国用扁形孔来充电//现在他到了欧洲,欧洲充电是圆形孔//目标接口interface Europe{ public function round();}//适配器,包含源接口,实现(继承)目标接口class European implements Eu... 阅读全文
posted @ 2014-11-17 11:48 tai君 阅读(174) 评论(0) 推荐(0) 编辑
摘要: name = $name; } public function setType($type){ $this->type = $type; } public function setPrice($price){ $this->price = $price; } public function ... 阅读全文
posted @ 2014-11-14 19:50 tai君 阅读(428) 评论(0) 推荐(0) 编辑
摘要: data = $data; $this->next = $next; }}class Linklist{ public $header; public function __construct(){ $this->header = new Node(null); } //向尾部添加结点 pu... 阅读全文
posted @ 2014-11-13 11:29 tai君 阅读(285) 评论(0) 推荐(0) 编辑
摘要: getName(),' visitd by ConcerteVisitor1 '; } public function visitConcreteElementB(ConcreteElementB $elementB){ echo $elementB->ge... 阅读全文
posted @ 2014-11-12 15:37 tai君 阅读(659) 评论(0) 推荐(0) 编辑
摘要: interpreter($temp); } }}$obj = new Interpreter();$obj->execute("sdf12345abc");?> UML 类图如下: 阅读全文
posted @ 2014-11-12 13:56 tai君 阅读(221) 评论(0) 推荐(0) 编辑
摘要: author = $author; $this->title = $title; } public function getTitle(){ return $this->title; } public function getAuthor(){ return $this->author; ... 阅读全文
posted @ 2014-11-10 22:11 tai君 阅读(254) 评论(0) 推荐(0) 编辑