学习面向对象马上快要两周的时间了,怎么来说,感觉我是有收获也有不懂的,还是讲的有些太深奥,我也不是能够完全理会。
下面示例一个我们所学的代码-简单对象
<?php/** * Created by PhpStorm. * User: fu * Date: 2017/7/18 * Time: 11:38 */ /* * 周末练习: 1 根据描述定义出对应的功能类、接口等: 银行柜台常规的功能有:存款、取款、转账、查询、修改密码等; ATM机也具有类似的功能:存款、取款、转账、查询、修改密码等; 但是银行柜台可以人工操作服务。 另外不同的银行可以提供一些特殊的便民服务: 中国银行可以交水、电、气等费用; 建设银行可以交水、电费,同时还可以交上网费; 交通银行可以交水费,还可以交交通违章费用; 工商银行可以交电、气费,还可以交有线电视费; 另外现在网络也和发达,那么支付宝和微信都可以支持上面的特殊费用的提交。 */ abstract class YinHang{ private $yinHangMingChen; private $yinHangZhangHao; private $miMa; public function cunKuan(){ } public function quKuan(){ } public function zhuanZhang(){ } public function chaXun(){ } public function xiuGaiMiMa(){ }}interface IShui{ function jiaoShuiFei();}interface IDian{ function jiaoDianFei();}interface IQi{ function jiaoQiFei();}interface IShangWang{ function jiaoShangWangFei();}interface IWeiZhang{ function jiaoWeiZhangFei();}interface IDianShi{ function jiaoDianShiFei();}class ZhongGuoYinHang extends YinHang implements IShui,IDian,IQi { function jiaoShuiFei(){ } function jiaoDianFei(){ } function jiaoQiFei(){ }}class JianSheYinHang extends YinHang implements IShui,IDian,IShangWang{ function jiaoDianFei() { // TODO: Implement jiaoDianFei() method. } function jiaoShangWangFei() { // TODO: Implement jiaoShangWangFei() method. } function jiaoShuiFei() { // TODO: Implement jiaoShuiFei() method. }}class JiaoTongYinHang extends YinHang implements IShui, IWeiZhang{ function jiaoShuiFei() { // TODO: Implement jiaoShuiFei() method. } function jiaoWeiZhangFei() { // TODO: Implement jiaoWeiZhangFei() method. }}class GongShangYinHang extends YinHang implements IDian, IQi, IDianShi{ function jiaoDianFei() { // TODO: Implement jiaoDianFei() method. } function jiaoDianShiFei() { // TODO: Implement jiaoDianShiFei() method. } function jiaoQiFei() { // TODO: Implement jiaoQiFei() method. }} class RenGongGuiTai{ private $yinHang; public function __construct($yinHang) { $this->yinHang = $yinHang; } public function renGongFuWu(){ echo ‘人工柜台可以提供人工服务‘; }}class ATM{ private $yinHang; public function __construct($yinHang) { $this->yinHang = $yinHang; }} abstract class WangLuoZhiFu implements IDianShi,IDian,IQi,IWeiZhang,IShui,IShangWang { private $name; private $zhangHao; private $miMa; public function __construct($name) { $this->name = $name; } function jiaoQiFei() { // TODO: Implement jiaoQiFei() method. } function jiaoDianShiFei() { // TODO: Implement jiaoDianShiFei() method. } function jiaoDianFei() { // TODO: Implement jiaoDianFei() method. } function jiaoWeiZhangFei() { // TODO: Implement jiaoWeiZhangFei() method. } function jiaoShuiFei() { // TODO: Implement jiaoShuiFei() method. } function jiaoShangWangFei() { // TODO: Implement jiaoShangWangFei() method. }} class ZhiFuBao extends WangLuoZhiFu{ }class WeiXin extends WangLuoZhiFu{ }这是一个简单的创建银行对象,但是对应的代码方法等还未实现。
时间: 2024-11-05 13:51:24