第五章
来源:互联网 发布:淘宝优惠微信群 编辑:程序博客网 时间:2024/06/08 18:28
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Dome1{ class Class1 { public string name; public string place; public int score; public double price; Class1 [] class1=new Class1[3]; public void Showinfo() { class1[0]=new Class1(); class1[0].name="杯子"; class1[0].place="第一厂库第一排"; class1[0].score = 108; class1[0].price = 17.02; class1[1] = new Class1(); class1[1].name = "花瓶"; class1[1].place = "第一厂库第二排"; class1[1].score = 99; class1[1].price = 10.02; class1[2] = new Class1(); class1[2].name = "热水器"; class1[2].place = "第一厂库第三排"; class1[2].score = 102; class1[2].price = 9.02; Console.WriteLine("库存商品清单列表:"); Console.WriteLine("------------------------"); for (int i = 0; i < class1.Length; i++) { Console.WriteLine("商品名称:" + class1[i].name); } Console.WriteLine("------------------------"); } public void Show() { Showinfo(); bool flag=true; do { Console.WriteLine("=======================欢迎使用库存管理系统====================="); Console.WriteLine("1.根据商品的名称获取商品的位置 2.取得客户满意度最高的货品 3.退出"); Console.WriteLine("================================================================"); Console.WriteLine("请选择:"); int num = int.Parse(Console.ReadLine()); switch (num) { case 1: Show1(); break; case 2: Show2(); break; case 3: flag = false; break; default: Console.WriteLine("输入的货品的名称错误!"); break; } } while (flag); } public void Show1() { Console.WriteLine("请输入货品的名称:"); string name = Console.ReadLine(); for (int i = 0; i < class1.Length; i++) { if(name.Equals(class1[i].name)){ Console.WriteLine(class1[i].place); break; } else if (i == class1.Length - 1) { Console.WriteLine("没有找到!"); } } } public void Show2() { int max = 0; for (int i = 0; i < class1.Length; i++) { if(class1[i].score>max){ max = class1[i].score; Console.WriteLine("温馨提示:"); Console.WriteLine("满意度最高的货品:"+class1[i].name+"摆在:"+class1[i].place+"满意度:"+max+"价格:"+class1[i].price); break; } } } }}
测试类
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace Dome1{ class Program { static void Main(string[] args) { Class1 v = new Class1(); v.Show(); Console.ReadLine(); } }}
0 0
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- 第五章
- python 的日志logging模块学习
- hadoop 四种压缩格式
- Egret的帧动画的使用
- poj 2823 Sliding Window 单调队列
- Spring事务管理(详解+实例)
- 第五章
- StringUtils工具类
- Log4的配置
- WordCount 到 Hdfs
- Axure8.0基础教程(41-50)新手必须掌握的基础操作
- Android处理未捕获的异常Application应用生命周期变量
- Android 中获取设备的宽高
- 第三篇 Android Bootloader 之 U-boot
- PYQT笔记——QTableView