首页 > 代码库 > 面向对象的一些题,让你快速了解基本写法
面向对象的一些题,让你快速了解基本写法
刚接触面向对象,对其非常不了解,接下老师用了一天时间出了一些题让我 们尽量快速进入到面向对象的学习中
事列:
<?php
/**
* Created by PhpStorm.
* User: fu
* Date: 2017/7/18
* Time: 16:39
*/
/*
* 根据描述定义出对应的功能类、接口等:
银行柜台常规的功能有:存款、取款、转账、查询、修改密码等;
ATM机也具有类似的功能:存款、取款、转账、查询、修改密码等;
但是银行柜台可以人工操作服务。
另外不同的银行可以提供一些特殊的便民服务:
中国银行可以交水、电、气等费用;
建设银行可以交水、电费,同时还可以交上网费;
交通银行可以交水费,还可以交交通违章费用;
工商银行可以交电、气费,还可以交有线电视费;
另外现在网络也和发达,那么支付宝和微信都可以支持上面的特殊费用的提交。
那么请大家根据上面的描述来进行设计。
*/
abstract class YinHang{
protected $yhMingChen;
public function __construct($yhMingChen)
{
$this->yhMingChen = $yhMingChen;
}
public function chaXun($chuHu){
}
public function cunKuan($chuHu){
}
public function quKuan($chuHu){
}
public function zhuanZhang($chuHu){
}
public function gaiMiMa($chuHu){
}
/**
* @return mixed
*/
public function getYhMingChen()
{
return $this->yhMingChen;
}
}
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()
{
// TODO: Implement jiaoShuiFei() method.
}
function jiaoDianFei()
{
// TODO: Implement jiaoDianFei() method.
}
function jiaoQiFei()
{
// TODO: Implement jiaoQiFei() method.
}
}
class JianSheYinHang extends YinHang implements IShui,IDian,IShangWang {
function jiaoDianFei()
{
// TODO: Implement jiaoDianFei() method.
}
function jiaoShuiFei()
{
// TODO: Implement jiaoShuiFei() method.
}
function jiaoShangWangFei()
{
// TODO: Implement jiaoShangWangFei() 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 jiaoQiFei()
{
// TODO: Implement jiaoQiFei() method.
}
function jiaoDianShiFei()
{
// TODO: Implement jiaoDianShiFei() method.
}
}
class RenGongGuiTai{
protected $name;
protected $yinHang;
public function __construct($yinHang, $name){
$this->yinHang = $yinHang;
$this->name = $name;
}
public function desc(){
echo ‘当前您访问的是:‘.$this->yinHang->getYhMingChen().$this->name;
}
public function renGongFuWu(){
}
}
class ATM{
protected $name;
protected $yinHang;
public function __construct($yinHang, $name){
$this->yinHang = $yinHang;
$this->name = $name;
}
}
abstract class TeShuZhiFu implements IDian,IQi,IDianShi,IShui,IWeiZhang,IShangWang{
protected $name;
public function __construct($name){
$this->name = $name;
}
public function desc(){
echo ‘当前您访问的是:‘.$this->name;
}
function jiaoDianFei()
{
echo "你好:需要交电费吗?";
}
function jiaoShuiFei()
{
// TODO: Implement jiaoShuiFei() method.
}
function jiaoShangWangFei()
{
// TODO: Implement jiaoShangWangFei() method.
}
function jiaoQiFei()
{
// TODO: Implement jiaoQiFei() method.
}
function jiaoDianShiFei()
{
// TODO: Implement jiaoDianShiFei() method.
}
function jiaoWeiZhangFei()
{
// TODO: Implement jiaoWeiZhangFei() method.
}
}
class ZhiFuBao extends TeShuZhiFu{
}
class WeiXing extends TeShuZhiFu{
}
$zfb=new ZhiFuBao(‘支付宝‘);
$zfb->desc();
echo "<br>";
$zfb->jiaoDianFei();
//$yh = new ZhongGuoYinHang(‘中国银行‘);
//$yhgt = new RenGongGuiTai($yh, ‘人工柜台‘);
//$yhgt->desc();
面向对象的一些题,让你快速了解基本写法
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。