银行收银系统(C#)

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


思路:  分三大块    一部分是显示出来的商品   一部分是用来存储商品的仓库  一部分是销售商品的 平台     仓库是分门别类的放置商品的  应该先给仓库添加货架


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)
        { <

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值