动物园管理系统实验报告

  • 格式:doc
  • 大小:251.59 KB
  • 文档页数:19
}
else
{
cout<<"文件中没有该信息!"<<endl;
}
}
cout<<"******************************************************************************"<<endl;
mainmenu();
}
//已存查询
void Manage::read()
#include"Manage.h"
#include"Message.h"
using namespace std;
class Tiger:public Manage
{
public:
void show(){cout<<"老虎的信息";}
};
#include<iostream>
#include"Manage.h"
三.UML类图
animal
+set_id():void
+get_id():int
~id:int
tiger
+show():void
~motion:int
horse
+show():void
~speed:int
panda
+show():void
~hobby:int
五.数据流图
1.总体数据流图:
从文件读出数据数据
cout<<"\t\t\t\t喂食间隔时间:"<<t.m_interval<<"\n";
动物园管理系统实验报告
一.时间:2010年12月2日星期一星期四
地点:软件楼506实验室
二.实验目的:
(1)使学生掌握C++编程的基本工作原理;
(2)培养学生基本掌握C++应用编程的基本思路和方法;
(3)使学生掌握C++应用调试的基本技能;
(4)培养学生分析、解决问题的能力;
(5)提高学生的科技论文写作能力。
{
ifile.seekg(i*184);
ifile.read((char *)&t,sizeof(t));
if(t.m_id==id)
{
cout<<"\t\t\t\t动物编号:"<<t.m_id<<"\n";
cout<<"\t\t\t\t喂食间隔时间:"<<t.m_interval<<"\n";
cout<<"\t\t\t\t食物名称:"<<t.m_food<<"\n";
//构造函数,strcpy(date,d)复制函数,将d复制给date
~ill(){};
void set_reason(char *r){strcpy(reason,r);}
char *get_reason(){return reason;}
void set_date(char *d){strcpy(date,d);}
附录:实验代码
//Animal.h
#ifndef Animal_h
#define Animal_h
#include<iostream>
#include"Feed.h"
#include"ill.h"
//========================================================
cout<<"\t\t\t\t喂食次数:"<<t.m_times<<"\n";
cout<<"\t\t\t\t得病原因:"<<t.m_reason<<"\n";
cout<<"\t\t\t\t得病时间:"<<t.m_date<<"\n";
cout<<"\t\t\t\t得病地点:"<<t.m_place<<endl<<endl<<endl;

2.模块数据流图
数据浏览:
数据查询:数据录入:
数据修改:
数据删除:
六.界面的设计
界面设计截图:
1.主菜单界面设计
2.浏览界面:
3.录入界面的设计
七.课程设计的心得
通过本次实验我能够基本掌握面向对象程序设计的基础知识,在对动物园管理系统的编写过程中了解了面向对象程序设计的应用,也在上机实践和对程序调试的同时提高了自己解决问题的能力。
cout<<"\t\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"\t\t\t·您只需按提示输入动物的信息·"<<endl;
cout<<"\t\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl<<endl<<endl;
do
#include"Message.h"
using namespace std;
class panda:public Manage
{
public:
void show(){cout<<"熊猫的信息";}
};
#include<iostream>
#include<fstream>
#include<string>
cout<<"\t\t\t 1.返回上一级2.退出系统"<<endl;
a:
cin>>command;
switch(command)
{
case 1:mainmenu();break;
case 2:return ;
default:
cout<<"您输入错误,请重新输入!"<<endl;
goto a;
}
}while(command==1||command==2);
using namespace std;
class Animal:public Feed,public ill
{
private:
int id;
public:
Animal(){};
Animal(int i,char *f,int t,char *r,char *d,char *p,int ID):Feed(i,f,t),ill(r,d,p)
char *get_date(){return date;}
void set_place(char *p){strcpy(place,p);}
char *get_place(){return place;}
};
#endif
//Feed.h
#ifndef Feed_h
#define Feed_h
#include<iostream>
#include"Animal.h
#include"Manage.h"
//#include"Save.h"
//================================================
using namespace std;
//本机帮助
void Manage::help()
{
int command;
1.13
主要功能是按照用户的要求查询动物信息。。
1.14
方便信息的查询。
数据录入:
数据查询:
输入动物编号
有数据,输出,否,退出查询模块
数据修改:
数据查询
决定是否修改
是,修改;否退出查询功能模块
数据删除;
数据查询
决定是否查询
是,XP
开发软件: Visual C++ 6.0
{
ifstream ifile("animal.dat",ios_base::in);
Message t;
int m=0;
ifstream animal("sum.dat",ios_base::in);
animal.read((char *)&m,sizeof(m));
animal.close();
}
//查询动物
void Manage::search()
{
int id,i,m=0;
Message t;
cout<<"******************************************************************************"<<endl;
cout<<"请输入要查询的动物编号:"<<endl;
在这段时间的上机实践中,我学会了很多,了解了如何应用Microsoft Visual C++环境实现工程的创建,类的生成等,可以说这次上机让我对课堂所学的知识有了更好的理解。深刻的体会到了面向对象程序设计在工程中应用的重要作用,及其对工程方面程序设计的深远影响。