首页 天轰穿个人书店类

天轰穿个人书店类

举报
开通vip

天轰穿个人书店类天轰穿个人书店类 /************************************************* * 晕 了,百度不支持CS文件上传,上传了TXT你们自己想办法吧 * * 天轰穿视频教学之个人书店之类源代码 * * 版权川哥所有,如果发现我不能发表请及时通知我 * 我在第一时间下架~ * * 2010-7-30 23:04:33 * * Sell类的外露属性因为这啊,那啊的问题没有写出来 * 不好意思啊~ * * **************************...

天轰穿个人书店类
天轰穿个人书店类 /************************************************* * 晕 了,百度不支持CS文件上传,上传了TXT你们自己想办法吧 * * 天轰穿视频教学之个人书店之类源代码 * * 版权川哥所有,如果发现我不能发表请及时通知我 * 我在第一时间下架~ * * 2010-7-30 23:04:33 * * Sell类的外露属性因为这啊,那啊的问 快递公司问题件快递公司问题件货款处理关于圆的周长面积重点题型关于解方程组的题及答案关于南海问题 没有写出来 * 不好意思啊~ * * ***********************************************/ using System; using System.Collections.Generic; using System.Text; namespace EBook { /// /// 会员类型 /// public enum U_Type { member,//会员 shopper,// } /// /// 书的类型 /// public enum B_Type { novel, lift, magazine, } /// /// 交易类型 /// public enum S_Type { sell, hire } /// /// 租借类型,租借,归还 /// public enum H_Type { rent, back } /// /// 定义接口返回本次交易的 /// 钱,执行最后插入数据库的操作 /// public interface Money { double GetMoney(); string Execute(); } public abstract class Root : Money { protected U_Type _utype;//会员类型 protected B_Type _btype;//书的类型 protected S_Type _stype;//交易类型 protected string _bookname;//书名 protected string _uname;//用户名 protected double _price;//书的定价 protected double _cash;//实际支付现金,不管是租还是还或是买书,他都 什么? public abstract double GetMoney(); public abstract string Execute(); } /// /// 作为销售子类的一个基类,这个类实际上没有工作的,主要是针对接口和基类做一 些???? /// public abstract class Sell : Root { /// /// 初始化该类 /// /// 用户名 /// 书名 /// 书的定价 public Sell(string un, string bn, double p) { _uname = un; _bookname = bn; _price = p; } #region 外露属性(定价,书名,用户名) #endregion #region 实现基类中的抽象方法以及任务分派到下面的派生类去 /// /// 实现基类的抽象方法,但是考虑到还需要再下级的派生类来完成 /// 所以我们选择让他们调用他能够被派生类修改的方法 /// /// public override double GetMoney() { return TGetMoney(); } public override string Execute() { return TExecute(); } /// /// 在这里我们并不处理,而是叫给处理他派生类来完成 /// /// public virtual double TGetMoney() { return 0; } /// /// 在这里我们并不处理,而是叫给处理他派生类来完成 /// /// public virtual string TExecute() { return ""; } #endregion } /// /// 作为租赁业务的一个基类,帮助实现ROOT类并增加租赁相关的属性和方法 /// public abstract class Hire : Root { #region 系列的私有字段 /// /// 租赁天数 /// protected int _day; /// /// 书的押金 /// protected double _deposit; #endregion #region 外露属性(定价,书名,用户名,天数,日租金) /// /// 获取书的定价 /// public double Price { get { return _price; } } /// /// 获取用户名称 /// public string Uname { get { return _uname; } } /// /// 获取书的名称 /// public string Bname { get { return _bookname; } } /// /// 获取或设置租赁的天数 /// public int Day { get { return _day; } set { _day = value; } } /// /// 获取或设置书和押金 /// public double Deposit { get { return _deposit; } set { _deposit = value; } } /// /// 实收的现金 /// public double Cash { get { return _cash; } set { _cash = value; } } #endregion #region 实现基类中的抽象方法以及任务分派到下面的派生类去 /// /// 实现基类的抽象方法,但是考虑到还需要再下级的派生类来完成 /// 所以我们选择让他调用其他能够派生类修改的方法 /// /// public override double GetMoney() { return TGetMoney(); } public override string Execute() { return TExecute(); } /// /// 在这里我们并不处理,而是叫给处理他的派生类来完成 /// /// public virtual double TGetMoney() { return 0; } /// /// 在这里我们并不处理,而是叫给处理他的派生类来完成 /// /// public virtual string TExecute() { return ""; } #endregion } /// /// 这个类处理会员购买书, 我们假设都 只是买一本,要买多本的朋友自己想办法,哈哈 /// public class Buy : Sell { public Buy(B_Type bt, string un, string bn, double p):base(un,bn,p) { _btype = bt; _uname = un; _bookname = bn; _price = p; } /// /// 根据书的类型来定价折扣,当然,这里的折扣本来是应该从数据库或者配置文件中取的 /// /// public override double TGetMoney() { switch (_btype) { case B_Type.novel: _cash = _price * 0.5; break; case B_Type.lift : _cash = _price * 0.8;break ; default: _cash = _price; break; } return _cash; } /// /// 执行插入数据库的操作,但是我们这里不需要,只要把结果显示出来 /// 所以我们让他给我们返回一保存话就OK了! /// /// public override string TExecute() { return string.Format("尊敬的会员:{0},你购买《{1}》,定价为:{2},折扣后为:{3}",_uname ,_bookname ,_price ,GetMoney().ToString ()); } } /// /// 增加有个处理零售客户类,大致逻辑是一样的,只是说折扣不同 /// public class SBuy : Sell { public SBuy(B_Type bt, string un, string bn, double p) : base(un, bn, p) { _btype = bt; _uname = un; _bookname = bn; _price = p; } /// /// 根据书的类型来定价折扣,当然,这里的折扣本来是应该从数据库或者配置文件中取的 /// /// public override double TGetMoney() { switch (_btype) { case B_Type.novel: _cash = _price * 0.6; break; case B_Type.lift : _cash = _price * 0.9;break ; default: _cash = _price; break; } return _cash; } /// /// 执行插入数据库的操作,但是我们这里不需要,只要把结果显示出来 /// 所以我们让他给我们返回一保存话就OK了! /// /// public override string TExecute() { return string.Format("尊敬的会员:{0},你购买《{1}》,定价为:{2},折扣后 为:{3}", _uname, _bookname, _price, GetMoney().ToString()); } } /// /// 工厂类主要是按照会员类型将具体使用那个类型返回出去 /// public class Factory { private U_Type _utype;//会员类型 private B_Type _btype;//书的类型 private S_Type _stype;//交易类型 private H_Type _htype;//是租书还是还书 private string _bookname;//书名 private string _uname;//用户名 private double _price;//书的定价 private int _day;//租借天数 public Factory(U_Type ut, B_Type bt, S_Type st, string bn, string un, double p) { _utype = ut; _btype = bt; _bookname = bn; _uname = un; _stype = st; _price = p; } /// /// 因为这个并不参与到最初的类实例化中去 /// 比如是买书,那根本谈不上是租还是还,所以单独列出来 /// public H_Type Htype { get { return _htype; } set { _htype = value; } } public int Day { get { return _day; } set { _day = value; } } /// /// 根据交易类型来判断给那一个方法处理 /// /// public Root HorS() { if (_stype == S_Type.hire) { return GetHire(); } else { return GetBuy(); } } /// ///根据交易类型来判断给那一个被初始化的类 /// /// private Sell GetBuy() { if (_utype == U_Type.member) { return new Buy(_btype, _uname, _bookname, _price); } else return new SBuy(_btype, _uname, _bookname, _price); } /// /// 根据是租书还是还是(又判断用户类型)来初始化对应的类 /// /// public Hire GetHire() { if (_htype == H_Type.rent) return new Rent(_uname, _bookname, _price); else { if (_utype == U_Type.member) return new M_Back(_uname, _bookname, _day, _btype); else return new S_Back(_uname, _bookname, _day, _btype); } } } /// /// 租书 /// 分析:租书的时候是不需要支付租金的,但是需要支付押金 /// public class Rent : Hire { /// /// 初始化对象 /// /// 用户名 /// 书名 /// 书的定价 public Rent(string un, string bn, double p) { _uname = un; _bookname = bn; _price = p; } public override double TGetMoney() {///直接返回实际支付的现金 return _cash; } //将顾客支付的押金写入数据库,这里我们是打印出来 public override string TExecute() { return string.Format("尊敬的顾客,您租借《{0}》,本书定价为:{1}元,请支付押金{2}元,实际支付{3}元",_bookname ,_price,_price ,TGetMoney ().ToString ()); } } /// /// 会员还书 /// 分析:还书的时候需要退还押金并支付租金,我们直接把租金在押金里面硬性扣除 /// 不同的是这个是会员还书,所以租金和普通顾客的租金区别 /// public class M_Back : Hire { /// /// 初始化对象 /// /// 用户名 /// 书名 /// 租赁天数 /// 书的类型 public M_Back(string un,string bn,int day,B_Type bt) { _uname = un; _bookname = bn; _day = day; _btype = bt; } public override double TGetMoney() {//直接返回应找零现金 return _deposit - GetRent(); } /// /// 计算书的租金 /// /// private double GetRent() { switch (_btype) { case B_Type.novel: _cash = Convert.ToDouble(_day) * 0.1; break; case B_Type.lift: _cash = Convert.ToDouble(_day) * 0.5; break; case B_Type.magazine: _cash = Convert.ToDouble(_day) * 0.1; break; }return _cash ; } /// /// 将顾客支付的押金写入数据库,这里我们是打印出来 /// /// public override string TExecute() { return string.Format("尊敬的顾客,您租借《{0}》,共计:{1}天,已支付押金{2},实际产生租金{3}元,应找您{4}元",_bookname ,_day ,_deposit,GetRent ().ToString (),TGetMoney ().ToString () ); } } public class S_Back : Hire { /// /// 初始化对象 /// /// 用户名 /// 书名 /// 租赁天数 /// 书的类型 public S_Back(string un,string bn,int day,B_Type bt) { _uname = un; _bookname = bn; _day = day; _btype = bt; } public override double TGetMoney() {//直接返回应找零现金 return _deposit - GetRent(); } /// /// 计算书的租金 /// /// private double GetRent() { switch (_btype) { case B_Type.novel: _cash = Convert.ToDouble(_day) * 0.5; break; case B_Type.lift: _cash = Convert.ToDouble(_day) * 1d; break; case B_Type.magazine: _cash = Convert.ToDouble(_day) * 0.3; break; } return _cash; } /// /// 将顾客支付的押金写入数据库,这里我们是打印出来 /// /// public override string TExecute() { return string.Format("尊敬的顾客,您租借《{0}》,共计:{1}天,已支付押金{2},实际产生租金{3}元,应找您{4}元", _bookname, _day, _deposit, GetRent().ToString(), TGetMoney().ToString()); } } }
本文档为【天轰穿个人书店类】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_260251
暂无简介~
格式:doc
大小:43KB
软件:Word
页数:0
分类:
上传时间:2017-11-12
浏览量:5