思路: 分三大块 一部分是显示出来的商品 一部分是用来存储商品的仓库 一部分是销售商品的 平台 仓库是分门别类的放置商品的 应该先给仓库添加货架
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.Tasks;
namespace 收银系统
{
class Enough : Discount
{
//定义自动属性存储买了多少钱
public decimal Buy
{
get;
set;
}
//定义自动属性存储应该少多少钱
public decimal Sell
{
get;
set;
}
//通过构造函数把买了多少钱,应该减多少钱传进去
public Enough(decimal buy,decimal sell)
{
<

这是一个使用C#编写的收银系统,包括商品显示、仓库管理、销售平台等模块。系统中定义了不同商品类如Acer、Banana,并实现了折扣功能,包括按比例打折和满额减价。此外,还有SuperMarket类用于处理客户与工作人员的交互,如库存显示、商品购买和打折计算。
最低0.47元/天 解锁文章
1398

被折叠的 条评论
为什么被折叠?



