05
来源:互联网 发布:强制粉碎文件软件 编辑:程序博客网 时间:2024/04/27 15:27
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication5{ /// <summary> /// 货品类 /// </summary> public class Goods { /// 货品名称 private string goodsName; public string GoodsName { get { return goodsName; } set { goodsName = value; } } /// 货品位置 private string goodsPlace; public string GoodsPlace { get { return goodsPlace; } set { goodsPlace = value; } } // 货品满意度 private int goodPleased; public int GoodPleased { get { return goodPleased; } set { goodPleased = value; } } /// 价格 private float goodPrice; public float GoodPrice { get { return goodPrice; } set { goodPrice = value; } } }}
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication5{ /// <summary> /// 库存类 /// </summary> public class Storage { /// <summary> /// 定义初始化数组 /// </summary> Goods[] goods = new Goods[3]; /// <summary> /// 初始化 /// </summary> public void shuju() { this.goods[0] = new Goods(); this.goods[0].GoodsName = "杯子"; this.goods[0].GoodsPlace = "第一仓库第一排"; this.goods[0].GoodPleased = 97; this.goods[0].GoodPrice = 15.25f; this.goods[1] = new Goods(); this.goods[1].GoodsName = "花瓶"; this.goods[1].GoodsPlace = "第一仓库第二排"; this.goods[1].GoodPleased = 96; this.goods[1].GoodPrice = 12.25f; this.goods[2] = new Goods(); this.goods[2].GoodsName = "热水器"; this.goods[2].GoodsPlace = "第一仓库第三排"; this.goods[2].GoodPleased = 99; this.goods[2].GoodPrice = 17.25f; } /// <summary> /// 输出货品名称 /// </summary> public void caidan() { Console.WriteLine("库存货品清单列表"); Console.WriteLine("--------------------------"); foreach (Goods good in this.goods) { Console.WriteLine("货品名称:" + good.GoodsName); } Console.WriteLine("--------------------------"); Console.WriteLine(); } /// <summary> /// 显示菜单 /// </summary> public void zhuye() { string option = ""; do { Console.WriteLine("\n=====================欢迎使用库存管理系统===================="); Console.WriteLine(" 1:根据货品名称获取货品位置 2:取得客户满意度最高的货品 3:退出"); Console.WriteLine("============================================================="); Console.WriteLine("请选择:"); option = Console.ReadLine(); switch (option) { case "1": if (this.huopinweizhi() == false) Console.WriteLine("您输入的货品名称不正确!"); //根据货品名称获取货品位置 break; case "2": //取得客户满意度最高的货品 this.xinxi(); break; case "3": Console.WriteLine("已退出库存管理系统,谢谢您的使用!"); return; default: Console.WriteLine("菜单选择错误,请重新输入选项!"); break; } } while (true); } /// <summary> /// 输出满意最高的货品信息 /// </summary> private void xinxi() { Goods good = new Goods(); good = manyihuoin(); string goodsName = string.Format("客户满意度最高的货品:{0}摆放在:{1} 满意度:{2} 价格:{3}", good.GoodsName, good.GoodsPlace, good.GoodPleased, good.GoodPrice); Console.WriteLine("温馨提示:"); Console.WriteLine(goodsName); } /// <summary> /// 得到满意最高的货品 /// </summary> /// <returns>最高值</returns> private Goods manyihuoin() { Goods good = new Goods(); good.GoodPleased = 0; foreach (Goods item in goods) { if (item.GoodPleased > good.GoodPleased) { good.GoodPleased = item.GoodPleased; good.GoodsName = item.GoodsName; good.GoodsPlace = item.GoodsPlace; good.GoodPrice = item.GoodPrice; } } return good; } /// <summary> /// 根据货品名称得到货品位置 /// </summary> /// <returns>存在指定的货品则返回true;否则返回false</returns> private bool huopinweizhi() { bool flag = false; Console.WriteLine("请输入货品名称"); string goods = Console.ReadLine().Trim(); foreach (Goods good in this.goods) { if (good.GoodsName.Equals(goods)) { flag = true; Console.WriteLine(good.GoodsPlace); } } return flag; } }}
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication5{ class Program { static void Main(string[] args) { Storage dept = new Storage(); //初始化数据 dept.shuju(); //输出菜单 dept.caidan(); } }}
0 0
- 05
- 05
- 05
- 05
- 05
- 05/07/05
- 05/09/05
- 05/10/05
- 10-05-05
- 2008/05/05
- CHAPTER 05:EX 05
- 2010-05-05
- 10 05 05 繁杂
- 2015-05-05
- 2005.10.05
- 2005.11.05
- 2006.01.05
- 2006.02.05
- Python实现下载ftp图片
- Effective Java读书笔记一(Java Tips.Day.1)
- OSX 下安装php7
- vsftpd安装和使用
- java笔试题集1
- 05
- 例题5-3 安迪的第一个字典 UVa10815
- SVN previous operation has not finished的问题
- 大数值
- 11.15
- jquery 常用代码片段
- SQL中Left Join 与Right Join 与 Inner Join 与 Full Join的区别
- squid命中率分析参数注释 -squidclient使用
- aop注解 自定义切面的注解写法