客户选购信息系统功能需求: 1)输入多个客户购买商品信息。包括客户名称,年龄,购买的商品,每种商品的单价和数量。 2)输出多个客户购买商品的信息。包括客户名字,年龄,购买商品,每种商品的单价和数量,总的消费金额。 方法:1)定义一个多个客户信息处理的类?CustomerGoodsAdmin?。包括: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 属性:?Customer?[ ]customers? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 方法:?void?show?()? ? ? ? ? ? ? //用户交互界面 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? void?inputCustomerlnfo?()? ? ?/?/客户采购信息输入 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Void?print?()//客户信息打印
2)定义一个?Customer?类。包括:
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 属性:?String?name? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int?age? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Goods?[ ]goodes? ? ? ? ? ? //采购商品 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? double?total? ? ? ? ? ? ? ? ? /?/总采购金额 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Customer?()? ? ? ? ? ? ? ? //构造方法
? ? ? ? ? ? ? ? ? ? ? ? ? ? ??print?()? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//输出客户信息 3)定义—个?Goods?类 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?属性:?String?name?//名称 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?int?num?//数量? ? ? ? ? ? ?double?price?//单价 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?double?totalPrice? ? ? ? ? //总价 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Goods?()? ? ? ? ? ? ? ? ? ?//构造方法 注意:所有属性都设置为?private?。通过get?、?set?访问 CustomerGoodsAdmin?类


?Customer?类

?
?
??Goods?类

?
测试结果:

?
由于题目比较简单,所以直接放图。并且是作者第一次写,不是很会排版和补充,望各位看官手下留情!!! (有错误欢迎指正,挨打要立正)
?
|