打印购物单
打印购物单
不需要过多的废话,直接看看代码吧!
using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 项目 { public class Goods { //字段 //名称 价格 位置 满意度 public string goodsName; public double goodsPrice; public string goodsPlace; public int goodsPleased; //属性 public string goodsName; { get { return name; } set { name = value; } } public double goodsPrice; { get { return price; } set { price = value; } } public string goodsPlace; { get { return position; } set { position = value; } } public int goodsPleased; { get { return manyidu; } set { manyidu = value; } } } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 项目 { class storage { Goods[] goods = new Goods[30]; //初始化库存货信息 public void Initial() { Goods good1 = new Goods(); good1.goodsPleased = 95; good1.goodsName = "杯子"; good1.goodsPrice=20; good1.goodsPlace= "第一仓库第二排"; goods[0] = good1; Goods good2 = new Goods(); good2.goodsPleased = 85; good2.goodsName = "花瓶"; good2.goodsPrice = 20; good2.goodsPlace = "第二仓库第二排"; goods[1] = good2; Goods good3 = new Goods(); good3.goodsPleased = 79; good3.goodsName = "热水器"; good3.goodsPrice = 20; good3.goodsPlace = "第三仓库第四排"; goods[2] = good3; } //显示库存管理系统菜单 public void ShowMenu() { bool flag = false;//定义一个标记,当用户输入3的时候将这个标记置成true while (flag==false) { Console.WriteLine("欢迎您来到聆听超市"); Console.WriteLine("1.根据武器名称获取物品位置 2.满意度最高的物品 3.退出"); Console.WriteLine("请您选择!"); string choice = Console.ReadLine(); switch (choice) { case "1": GetgoodsPlaceBygoodsName;(); break; case "2": GetPlease() ; break; case "3": flag = true; break; default: Console.WriteLine("退出啦啦啦啦啦!"); break; } } } //输出库存现有货品的名称 public void ShowGoods() { foreach (Goods item in goods) { if (item!=null) Console.WriteLine(item.goodsName); { } } } //根据货品名称得到货品位置 public void GetGoodsPlace() { Console.WriteLine("输入名称"); string name = Console.ReadLine(); foreach (Goods item in goods) { if (item!=null) { if (item.goodsName.Equals(name)) { Console.WriteLine(item.goodsPlace); } } } } //输出满意度最高的货品信息 public void GetMaxPleased(Goods temp) { Console.WriteLine("{0}{1}{2}{3}{4}",temp.goodsName,temp.goodsPlace,temp.goodsPleased,temp.goodsPrice,); } //获得满意度最高的商品 public void GetPlease() { for (int i = 0; i < goods.Length-i; i++) { for (int j = 0; j < goods.Length - i - 1; j++) { if (goods[j].goodsPleased < goods[j - 1].goodsPleased) { Goods temp = goods[j]; goods[j] = goods[j + 1]; goods[j + 1] = temp; } } } return goods[0]; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Shopping { class Program { static void Main(string[] args) { Storage kuCun=new Storage(); kuCun.Initial(); kuCun.ShowInfo(); kuCun.ShowMenu(); Console.ReadKey(); } } }
其实我也看不懂⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄
所以没什么话可说的
帅的人都点赞了 你还在犹豫什么?!!!