大连东软信息学院
三级项目报告
课程名:JAVA语言程序设计
实践项目:采购管理系统项目
学 院:大连东软信息学院
组长姓名:
指导教师:邵欣欣
20##年6月10日
第1章 构思
请对系统的需求进行详细的介绍(150字以上)
正文(以下章节凡语言描述部分都依照此格式要求)(格式要求:空两格、小四号宋体,1.5倍行距)
公司想投资研发新产品,生产制造并进行市场销售此种商品借此盈利。根据这样的问题,如何根据市场需求选择此种商品就成了需要解决的重要问题。于是借用随机数与switch选择语句结合,最终的选择结果用以模拟对市场进行调研的结果。由名为顺风耳的市场调查员来完成此工作,最后根据他的调查结果开发并生产新产品。
系统中有一个抽象的商品类(Goods),作为其子类的父类,定义所有产品所共有的属性和方法。之后每个商品作为该商品类的一个子类,定义其附加的属性、构造方法以及方法,并实现商品类中的抽象方法,用以模拟实现每一件商品的研发生产和销售过程。本小组项目中总共包含一个商品类Goods和六个具体的商品类Computer, XBox,Camera,Keyboard,Mobile phone作为该商品类的子类,实现具体商品的研发生产和销售过程。
同时小组程序中还包含两个类。Market Inquirer类用以模拟市场行情的变化,并返回热销产品的名称。Factory类用以返回创建该热销产品的对象,并用以实现具体的商品类中的研发,生产和销售的方法。最终用boss类创建各个类的对象并调用对应方法,最终实现该管理系统进行市场调研并根据调研结果开发新产品的目的。
第2章 设计
2.1应用的知识点
(1)类与对象的创建,包括属性定义,方法定义和对象的创建。
(2)访问权限修饰符的使用,包括默认修饰符和private,protected和public。方法和构造方法修饰符一般用public,属性一般为private,对于私有属性用访问器和设置器方法进行访问和修改。
(3)无参构造方法的定义,给类中的属性对象赋初始值。创建对象中调用该构造方法,用于对象的初始化。
(4)构造方法与一般方法的区别。
(5)对方法的调用:对象调用和类调用,有返回值的方法对方法的调用就当做处理一个值,没有返回值的调用就当做处理一条语句。
(6)类的继承。Java是单重继承,每个类都有一个父类,未定义的则继承Object类。子类可以继承父类的属性和构造方法,子类可以添加新的属性和方法,子类可以重新定义父类的属性和方法。
(7)子类是父类的特例,子类的对象也可以看做父类的对象。
(8)子类中定义了一个与父类方法头相同的方法,称为方法的覆盖。子类方法与父类方法的修饰符可以不同,但是子类方法只能扩大父类方法中的访问权限。
(9)抽象类只能用于继承,不能用于创建对象。
(10)抽象方法(abstract修饰)只有方法头没有方法体,只能定义在抽象类中,强制抽象方法必须在其子类中被实现。
(11)子类中必须覆盖抽象类中的全部抽象方法。
(12)this关键字用来指代当前类中的当前对象,可用来调用当前对象的成员。(this可以用来调用当前的构造方法,但必须写在构造方法中的第一条)。
(13)Java包的引入。
(14)数组的声明,初始化以及应用。
(15)字符串的声明,初始化以及String类中的常用方法。
2.2功能介绍
项目主要通过作为父类的抽象类goods和作为子类的具体商品类Mobile Phone等的编写,模拟实现具体商品的研发生产制造功能。同时通过Market Inquire类实现模拟市场调研结果,用Factory类辅助实现测试类功能的Boss类,利用多态性,创建对象并实现各个具体商品类之中研发,生产和销售的方法。
同时本小组还利用极其有限的图形用户界面设计的知识在程序实现目的功能的基础之上进行了少部分的功能添加。导入JAVA中JDK中的抽象窗口工具集的Swing包,实践一个简单的“显示调研结果”事件处理。
第3章 实施
3.1类的编写
GOOD类
package产品管理;
publicabstractclassGoods {
protectedString gno;
protectedString gname;
protecteddoublegprice;
abstractvoidresearch();
/**
* 生产制造
*/
abstractvoidproduct();
/**
* 投入市场
*/
abstractvoidsell();
}
package产品管理;
fatory类
publicclassFactory {
publicstaticGoods fatory(String which) {
if(which.equalsIgnoreCase("camera")) {
returnnewCamera();
}elseif(which.equalsIgnoreCase("computer")) {
returnnewComputer();
}elseif(which.equalsIgnoreCase("mobilephone")) {
returnnewMobilePhone();
}elseif(which.equalsIgnoreCase("XBox")) {
returnnewXBox();
}elseif(which.equalsIgnoreCase("Keyboard")) {
returnnewKeyboard();
}else{
returnnull;
}
}
}
Keyboard类
package产品管理;
publicclassKeyboardextendsGoods {
protectedString brand;
protectedString type;
protectedinta;
Keyboard() {
brand = "联想";
type = "K123";
gname = "键盘";
gprice = 68;
}
publicvoidresearch() {
for(inti = 0; i <= 100; i++) {
a = (int) (Math.random() * 2 + 1);
System.out.println(brand + type + gname + "正在研究开发中....");
if(a == 1) {
System.out.println(brand + type + gname + "研发成功!");
break;
}else
System.out.println(brand + type + gname + "研发失败!即将进行重新研发……");
}
}
publicvoidproduct() {
a = (int) (Math.random() * 10000);
System.out.println(brand + type + gname + "产品制造生产中……");
System.out.println(brand + type + gname + "已制造成功!" + "\n" + "共生产了" + a
+ "件" + brand + type + gname);
}
publicvoidsell() {
System.out.println(brand + type + gname + "产品热销中……");
System.out.println(brand + type + gname + "已经销售一空!");
System.out.println("商品型号为:" + type);
System.out.println("商品名称为:" + gname);
System.out.println("商品品牌为:" + brand);
System.out.println("商品市场价格为:" + gprice);
}
}
MarketInquirer类
package产品管理;
publicclassMarketInquirer {
String name;
MarketInquirer(String name) {
this.name = name;
}
/**
* 该方法模拟市场行情的变化,并返回热销产品的名称!
*/
publicString inquirer() {
switch((int) (Math.random() * 6)) {//多重选择
case0:
report("相机");
return"camera";
case1:
report("电脑");
return"computer";
case2:
report("手机");
return"mobilephone";
case3:
report("XBox");
return"XBox";
case4:
report("键盘");
return"Keyboard";
default:
report("键盘");
return"Keyboard";
}
}
privatevoidreport(String hotFruit) {
System.out.println("市场调研员" + name + "报告:经过周密调研,今年" + hotFruit
+ "会有好销路,请生产!");
}
}
MobilePhone类
package产品管理;
publicclassMobilePhoneextendsGoods {
/**
* 添加需要的属性和构造方法
*/
protectedString brand;
protectedinta;
MobilePhone() {
brand = "HTC";
gno = "111";
gname = "智能手机";
gprice = 1230;
}
/**
* 实现父类中的research()
*/
publicvoidresearch() {
for(inti = 0; i <= 100; i++) {
a = (int) (Math.random() * 2 + 1);
System.out.println(brand + gno + gname + "正在研究开发中……");
if(a == 1) {
System.out.println(brand + gno + gname + "研发成功!");
break;
}else
System.out.println(brand + gno + gname + "研发失败!即将进行重新研发……");
}
}
/**
* 实现父类中的product()
*/
publicvoidproduct() {
a = (int) (Math.random() * 10000);
System.out.println(brand + gno + gname + "正在制造生产中……");
System.out.println(brand + gno + gname + "已经制造成功!" + "\n" + "共生产了" + a
+ "件" + brand + gno + gname);
}
/**
* 实现父类中的sell()
*/
publicvoidsell() {
System.out.println(brand + gno + gname + "正在市场销售中……");
System.out.println(brand + gno + gname + "已经销售一空!");
System.out.println();
System.out.println("商品品牌为:" + brand);
System.out.println("商品型号为:" + gno);
System.out.println("商品名称为:" + gname);
System.out.println("商品价格为:" + gprice);
}
}
Xbox类
package产品管理;
publicclassXBoxextendsGoods {
protectedintb;
XBox() {
gno = "10120900128";
gname = "XBox360";
gprice = 1800;
System.out.println("商品批号为:" + gno);
System.out.println("商品名为:" + gname);
System.out.println("市场价为:" + gprice);
}
int[] a =newint[2];
inti = 0;
voidnum() {
a[i] = (int) (Math.random() * 2) + 1;
}
voidresearch() {
for(inti = 0; i <= 100; i++) {
System.out.println(gno + gname + "正在研究中……");
num();
if(a[i] == 1)
System.out.println(gno + gname + "研发失败!即将进行重新研发……");
else{
System.out.println(gno + gname + "研发成功!");
break;
}
}
}
voidproduct() {
b = (int) (Math.random() * 10000);
System.out.println(gno + gname + "正在生产中……");
System.out.println(gno + gname + "生产结束!" + "\n" + "共生产了" + b + "件"
+ gno + gname);
}
voidsell() {
System.out.println(gno + gname + "市场销售中……");
System.out.println(gno + gname + "已经销售一空!");
}
}
Camera类
package产品管理;
publicclassCameraextendsGoods {
/**
* 添加需要的属性和构造方法
*/
protectedString style;
protectedinta;
Camera() {
gno = "00001";
gname = "相机";
style = "sony";
gprice = 200;
}
/**
* 实现父类中的research()
*/
publicvoidresearch() {
for(inti = 0; i <= 100; i++) {
a = (int) (Math.random() * 2 + 1);
System.out.println(gno + style + gname + "正在研究开发中....");
if(a == 1) {
System.out.println(gno + style + gname + "研发成功!");
break;
}else
System.out.println(gno + style + gname + "研发失败!即将进行重新研发……");
}
}
/**
* 实现父类中的product()
*/
publicvoidproduct() {
a = (int) (Math.random() * 10000);
System.out.println(gno + style + gname + "正在制造生产中....");
System.out.println(gno + style + gname + "已经制造成功!" + "\n" + "共生产了" + a
+ "件" + gno + style + gname);
}
/**
* 实现父类中的sell()
*/
publicvoidsell() {
System.out.println(gno + style + gname + "正在市场销售中....");
System.out.println(gno + style + gname + "已经销售一空!");
System.out.println();
System.out.println("商品型号为:" + gno);
System.out.println("商品名称为:" + gname);
System.out.println("商品类型为:" + style);
System.out.println("商品市场价格为:" + gprice);
}
}
Computer类
package产品管理;
publicclassComputerextendsGoods {
/**
* 添加需要的属性和构造方法
*/
protectedString style;
protectedinta;
Computer() {
gno = "1000";
gname = "笔记本电脑";
style = "戴尔";
gprice = 5500;
}
/**
* 实现父类中的research()
*/
publicvoidresearch() {
for(inti = 0; i <= 100; i++) {
a = (int) (Math.random() * 2 + 1);
System.out.println(gno + style + gname + "正在研究开发中....");
if(a == 1) {
System.out.println(gno + style + gname + "研发成功!");
break;
}else
System.out.println(gno + style + gname + "研发失败!即将进行重新研发……");
}
}
/**
* 实现父类中的product()
*/
publicvoidproduct() {
a = (int) (Math.random() * 10000);
System.out.println(gno + style + gname + "正在制造生产中……");
System.out.println(gno + style + gname + "已经制造成功!" + "\n" + "共生产了" + a
+ "件" + gno + style + gname);
}
/**
* 实现父类中的sell()
*/
publicvoidsell() {
System.out.println(gno + style + gname + "正在市场销售中……");
System.out.println(gno + style + gname + "已经销售一空!");
System.out.println();
System.out.println("商品型号为:" + gno);
System.out.println("商品名称为:" + gname);
System.out.println("商品品牌为:" + style);
System.out.println("商品市场价格为:" + gprice);
}
}
3.2 主程序的编写
package 产品管理;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Boss implements ActionListener{
/**
* 公司根据市场调查员的反馈,安排一年的生产计划!
* @param args
*/
JFrame frame;
JDialog dialog;
JButton button;
String sname=" ";
public static void main(String args[]){
System.out.println("请输入调研员姓名:");
String sname = "顺风耳";
Boss jd=new Boss();
jd.go();
sname="优秀市场调研员"+sname+"的调研结果为公司带来了巨大经济收益!";
System.out.println(sname);
}
public void go(){
MarketInquirer mi = new MarketInquirer(sname= MyInput.readString());
String hotFruit = mi.inquirer();
Goods g = Factory.fatory(hotFruit);
frame=new JFrame("调研员");
dialog=new JDialog(frame,"调研反馈",true);
JButton button1=new JButton(sname);
JPanel contentPane=new JPanel();
contentPane.setLayout(new BorderLayout());
contentPane.add(button1,BorderLayout.CENTER);
frame.setContentPane(contentPane);
frame.pack();
frame.setVisible(true);
dialog.getContentPane().add(new JLabel("今年会有好销路的产品是:"+hotFruit));
dialog.setSize(250,150);
button =new JButton("查看调研结果");
button.addActionListener(this);
Container cp=frame.getContentPane();
cp.add(button,BorderLayout.EAST);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(250,150);
frame.setVisible(true);
g.research();
g.product();
g.sell();
}
public void actionPerformed(ActionEvent e){
dialog.setVisible(true);
}
}
第4章 运行
4.1程序的运行结果
4.2错误的解决方式
从其他包里拖入MyInput
Import 调用语句
小组成员贡献率
填表要求:
1.根据个人表现给定单个成绩;
2.个人成绩计算公式:
个人成绩=项目组成绩×个人贡献权重/项目组个人最高贡献权重
3. 小组成员个人贡献权重总和为100%,数据精确到个位。