ImageVerifierCode 换一换
格式:DOCX , 页数:20 ,大小:17.49KB ,
资源ID:10938768      下载积分:10 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/10938768.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(C#简单超市收银系统源码.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

C#简单超市收银系统源码.docx

1、C#简单超市收银系统源码C#简单超市收银系统源码using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace _16超市收银系统 class ProductFather public double Price get; set; public string Name get; set; public string ID get; set; public ProductFather(string id, double

2、price, string Name) this.ID = id; this.Price = price; this.Name = Name; using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace _16超市收银系统 class SamSung:ProductFather public SamSung(string id, double price, string Name) : base(id, price

3、, Name) using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace _16超市收银系统 class Acer:ProductFather public Acer(string id, double price, string Name) : base(id, price, Name) using System;using System.Collections.Generic;using System.Lin

4、q;using System.Text;using System.Threading.Tasks;namespace _16超市收银系统 class Banana : ProductFather public Banana(string id, double price, string Name) : base(id, price, Name) using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace _16超市

5、收银系统 class JiangYou:ProductFather public JiangYou(string id, double price, string Name) : base(id, price, Name) using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace _16超市收银系统 class SupperMarket /创建仓库对象 CangKu ck = new CangKu(); / /

6、创建超市对象的时候,给仓库的货架上导入货物 / public SupperMarket() ck.JinPros(Acer, 1000); ck.JinPros(SamSung, 1000); ck.JinPros(JiangYou, 1000); ck.JinPros(Banana, 1000); / / 跟用户交互的过程 / public void AskBuying() Console.WriteLine(欢迎观临,请问您需要些什么?); Console.WriteLine(我们有 Acer、SamSung、Jiangyou、Banana); string strType = Conso

7、le.ReadLine(); Console.WriteLine(您需要多少?); int count = Convert.ToInt32(Console.ReadLine(); /去仓库取货物 ProductFather pros = ck.QuPros(strType, count); /下面该计算价钱了 double realMoney = GetMoney(pros); Console.WriteLine(您总共应付0元, realMoney); Console.WriteLine(请选择您的打折方式 1-不打折 2-打九折 3-打85 折 4-买300送50 5-买500送100);

8、 string input = Console.ReadLine(); /通过简单工厂的设计模式根据用户的舒服获得一个打折对象 CalFather cal = GetCal(input); double totalMoney = cal.GetTotalMoney(realMoney); Console.WriteLine(打完折后,您应付0元, totalMoney); Console.WriteLine(以下是您的购物信息); foreach (var item in pros) Console.WriteLine(货物名称:+item.Name+,+t+货物单价:+item.Price+

9、,+t+货物编号:+item.ID); / / 根据用户的选择打折方式返回一个打折对象 / / 用户的选择 / 返回的父类对象 但是里面装的是子类对象 public CalFather GetCal(string input) CalFather cal = null; switch (input) case 1: cal = new CalNormal(); break; case 2: cal = new CalRate(0.9); break; case 3: cal = new CalRate(0.85); break; case 4: cal = new CalMN(300, 50)

10、; break; case 5: cal = new CalMN(500, 100); break; return cal; / / 根据用户买的货物计算总价钱 / / / public double GetMoney(ProductFather pros) double realMoney = 0; /realMoney = pros0.Price * pros.Length; for (int i = 0; i pros.Length; i+) realMoney += prosi.Price; / realMoney = prosi * pros.Length; return realM

11、oney; public void ShowPros() ck.ShowPros(); using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace _16超市收银系统 / / 不打折 该多少钱就多少钱 / class CalNormal:CalFather public override double GetTotalMoney(double realMoney) return realMoney; using S

12、ystem;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace _16超市收银系统 / / 按折扣率打折 / class CalRate:CalFather / / 折扣率 / public double Rate get; set; public CalRate(double rate) this.Rate = rate; public override double GetTotalMoney(double realMoney)

13、 return realMoney * this.Rate; using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace _16超市收银系统 / / 买M元 送N元 / class CalMN:CalFather /买500送100 public double M get; set; public double N get; set; public CalMN(double m, double n) this.M

14、= m; this.N = n; public override double GetTotalMoney(double realMoney) /600 -100 /1000-200 /1200 if (realMoney = this.M) return realMoney - (int)(realMoney / this.M) * this.N; else return realMoney; using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa

15、ding.Tasks;namespace _16超市收银系统 class CangKu ListList list = new ListList(); / /向用户展示货物 / public void ShowPros() foreach (var item in list) Console.WriteLine(我们超市有: + item0.Name + , + t + 有 + item.Count + 个, + t + 每个 + item0.Price + 元); /list0存储Acer电脑 /list1存储三星手机 /list2存储酱油 /list3存储香蕉 / / 在创建仓库对象的时候

16、 像仓库中添加货架 / public CangKu() list.Add(new List(); list.Add(new List(); list.Add(new List(); list.Add(new List(); / / 进货 / / 货物的类型 / 货物的数量 public void JinPros(string strType, int count) for (int i = 0; i count; i+) switch (strType) case Acer: list0.Add(new Acer(Guid.NewGuid().ToString(), 1000, 宏基笔记本);

17、 break; case SamSung: list1.Add(new SamSung(Guid.NewGuid().ToString(), 2000, 棒之手机); break; case JiangYou: list2.Add(new JiangYou(Guid.NewGuid().ToString(), 10, 老抽酱油); break; case Banana: list3.Add(new Banana(Guid.NewGuid().ToString(), 50, 大香蕉); break; / / 从仓库中提取货物 / / / / public ProductFather QuPros

18、(string strType, int count) ProductFather pros = new ProductFathercount; for (int i = 0; i pros.Length; i+) switch (strType) case Acer: prosi = list00; list0.RemoveAt(0); break; case SamSung: prosi = list10; list1.RemoveAt(0); break; case JiangYou: prosi = list20; list2.RemoveAt(0); break; case Bana

19、na: prosi = list30; list3.RemoveAt(0); break; return pros; using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace _16超市收银系统 class SupperMarket /创建仓库对象 CangKu ck = new CangKu(); / / 创建超市对象的时候,给仓库的货架上导入货物 / public SupperMarket() ck.JinP

20、ros(Acer, 1000); ck.JinPros(SamSung, 1000); ck.JinPros(JiangYou, 1000); ck.JinPros(Banana, 1000); / / 跟用户交互的过程 / public void AskBuying() Console.WriteLine(欢迎观临,请问您需要些什么?); Console.WriteLine(我们有 Acer、SamSung、Jiangyou、Banana); string strType = Console.ReadLine(); Console.WriteLine(您需要多少?); int count =

21、 Convert.ToInt32(Console.ReadLine(); /去仓库取货物 ProductFather pros = ck.QuPros(strType, count); /下面该计算价钱了 double realMoney = GetMoney(pros); Console.WriteLine(您总共应付0元, realMoney); Console.WriteLine(请选择您的打折方式 1-不打折 2-打九折 3-打85 折 4-买300送50 5-买500送100); string input = Console.ReadLine(); /通过简单工厂的设计模式根据用户的

22、舒服获得一个打折对象 CalFather cal = GetCal(input); double totalMoney = cal.GetTotalMoney(realMoney); Console.WriteLine(打完折后,您应付0元, totalMoney); Console.WriteLine(以下是您的购物信息); foreach (var item in pros) Console.WriteLine(货物名称:+item.Name+,+t+货物单价:+item.Price+,+t+货物编号:+item.ID); / / 根据用户的选择打折方式返回一个打折对象 / / 用户的选择

23、 / 返回的父类对象 但是里面装的是子类对象 public CalFather GetCal(string input) CalFather cal = null; switch (input) case 1: cal = new CalNormal(); break; case 2: cal = new CalRate(0.9); break; case 3: cal = new CalRate(0.85); break; case 4: cal = new CalMN(300, 50); break; case 5: cal = new CalMN(500, 100); break; re

24、turn cal; / / 根据用户买的货物计算总价钱 / / / public double GetMoney(ProductFather pros) double realMoney = 0; /realMoney = pros0.Price * pros.Length; for (int i = 0; i pros.Length; i+) realMoney += prosi.Price; / realMoney = prosi * pros.Length; return realMoney; public void ShowPros() ck.ShowPros(); using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace _16超市收银系统 class Program static void Main(string args) /创建超市对象 SupperMarket sm = new SupperMarket(); /展示货物 sm.ShowPros(); /跟用户交互 sm.AskBuying(); Console.ReadKey();

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1