c#第五章
来源:互联网 发布:备案的域名 编辑:程序博客网 时间:2024/06/16 19:06
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApplication9{ public class a { 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;using System.Threading.Tasks;namespace ConsoleApplication9{ public class b { a[] goods = new a[3]; public void Initial() { this.goods[0] = new a(); this.goods[0].GoodsName = "杯子"; this.goods[0].GoodsPlace = "第一仓库第一排"; this.goods[0].GoodPleased = 97; this.goods[0].GoodPrice = 15.25f; this.goods[1] = new a(); this.goods[1].GoodsName = "花瓶"; this.goods[1].GoodsPlace = "第一仓库第二排"; this.goods[1].GoodPleased = 96; this.goods[1].GoodPrice = 12.25f; this.goods[2] = new a(); this.goods[2].GoodsName = "热水器"; this.goods[2].GoodsPlace = "第一仓库第三排"; this.goods[2].GoodPleased = 99; this.goods[2].GoodPrice = 17.25f; } public void ShowGoods() { Console.WriteLine("库存货品清单列表"); Console.WriteLine("--------------------------"); foreach (a good in this.goods) { Console.WriteLine("货品名称:" + good.GoodsName); } Console.WriteLine("--------------------------"); Console.WriteLine(); } public void ShowMenu() { string option = ""; do { Console.WriteLine("\n=====================欢迎使用库存管理系统===================="); Console.WriteLine(" 1:根据货品名称获取货品位置 2:取得客户满意度最高的货品 3:退出"); Console.WriteLine("============================================================="); Console.WriteLine("请选择:"); option = Console.ReadLine(); switch (option) { case "1": if (this.GetGoodsPlace() == false) Console.WriteLine("您输入的货品名称不正确!"); break; case "2": this.GetMaxPleased(); break; case "3": Console.WriteLine("已退出库存管理系统,谢谢您的使用!"); return; default: Console.WriteLine("菜单选择错误,请重新输入选项!"); break; } } while (true); } private void GetMaxPleased() { a good = new a(); good = GetPleased(); string goodsName = string.Format("客户满意度最高的货品:{0}摆放在:{1} 满意度:{2} 价格:{3}", good.GoodsName, good.GoodsPlace, good.GoodPleased, good.GoodPrice); Console.WriteLine("温馨提示:"); Console.WriteLine(goodsName); } private a GetPleased() { a good = new a(); good.GoodPleased = 0; foreach (a 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; } private bool GetGoodsPlace() { bool flag = false; Console.WriteLine("请输入货品名称"); string goods = Console.ReadLine().Trim(); foreach (a 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;using System.Threading.Tasks;namespace ConsoleApplication9{ class Program { static void Main(string[] args) { b dept = new b(); dept.Initial(); dept.ShowMenu(); } }}
0 0
- c#第五章
- C#第五章
- C#第五章 上机
- C# 电子书 第五章
- C#入门经典第五章
- 05 C# 第五章 类
- C#第五章 套餐体检
- 看C# 第五章 复习基础知识
- C#入门经典—第五章
- c#第五章指导学习:库存管理
- c#图解教程 第五章 方法
- C#图解教程 第五章 方法
- C#第五次作业
- C#第五次作业
- c#第五次作业
- c#第五次作业
- C#第五次上机
- 阅读----C#图解教程第四章 第五章
- 前端HTML、CSS、JS绘制三角形的方法
- 直通交换转发计算
- 【NOIP模拟题】【DP】【LIS】【中缀表达式】2016.11.15 第一题 小L的二叉树 题解
- varchar和Nvarchar区别
- C++多态和虚表浅析
- c#第五章
- iOS设计模式浅析之组合模式
- Android进阶学习笔记(一) ---- 前言
- 逻辑运算学习笔记
- 设计模式之代理模式(第二篇)
- iOS相册内ALasset类对象是nil的问题
- 多人聊天小程序
- iOS设计模式浅析之责任链设计模式
- 算法设计例题:最大团(回溯、分枝限界)