思路: 分三大块 一部分是显示出来的商品 一部分是用来存储商品的仓库 一部分是销售商品的 平台 仓库是分门别类的放置商品的 应该先给仓库添加货架
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 收银系统
{
class Acer : ProductFather
{
public Acer(String name,decimal price, string id) : base(name,price,id)
{
}
}
}
----------------------------------------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 收银系统
{
class Banana:ProductFather
{
public Banana(String name, decimal price, string id) : base(name, price, id)
{
}
}
}
------------------------------------------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 收银系统
{
/// <summary>
/// 折扣
/// </summary>
abstract class Discount
{
/// <summary>
/// 折扣的抽象函数
/// </summary>
/// <param name="money">本应该付多少钱</param>
/// <returns>返回打折后应付的钱</returns>
public abstract decimal DiscountMethod(decimal money);
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 收银系统
{
/// <summary>
///按打折率打折的类,继承打折类
/// </summary>
class discountRate : Discount
{
//用自动属性存储打折率
public double Rate
{
get;
set;
}
//把打折率通过构造函数传进来
public discountRate(double rate)
{
this.Rate = rate;
}
/// <summary>
/// 重写打折的构造函数
/// </summary>
/// <param name="money">打折之前应该付多少钱</param>
/// <returns>返回打折后应付的钱</returns>
public override decimal DiscountMethod(decimal money)
{
return money * (decimal)this.Rate;
}
}
}
---------------------------------------------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tas