软件体系结构实验一实验报告.docx
《软件体系结构实验一实验报告.docx》由会员分享,可在线阅读,更多相关《软件体系结构实验一实验报告.docx(13页珍藏版)》请在冰豆网上搜索。
软件体系结构实验一实验报告
广西师范大学、计算机与信息工程学院
《软件体系结构》课程
实验一软件风格编程实验
一、实验内容
1、运用“隐式调用风格”即“事件驱动模式”设计程序界面系统。
2、学习了解基于事件驱动模式的编程的基本设计方法。
3、通过实验,学习和了解WINDOWS的程序平台上的设计实现方法。
二、实验条件
1、硬件环境:
单机/网络系统,X86系列计算机,TCP/IP网络平台
2、软件环境:
WIN9X/NT/2K/XP操作系统平台
3、开发环境:
VC++6.0开发平台、VC++2008开发平台
4、参考资料:
教材《VC++6.0程序设计教程》清华大学出版社
三、实验过程
步骤1:
系统的总体模块结构如图所示,系统基于功能相对独立的原则划分,尽量满足功能内聚的要求,总共由用户管理、客房管理、订房管理、结算管理、服务管理五大功能模块构成整体系统。
每个功能模块都根据自身的业务需求,设定了不同的子功能模块,进行进一步的业务细化。
步骤2:
将图示的调用结构用菜单消息实现。
(1)每个下层模块用子菜单呈现。
(2)底层模块用对话框实现。
过程:
1、运行VC++6.0开发平台,选择“文件”——“新建”——“MFCAppwizard(exe)”,工程名称设为“Hotel_MIS”,选择工程存放路径,确定
2、选择“单文档”,点击“完成”按钮,进入如图1界面
图1
3、选择“ResourceView”选项卡,依次展开“Hotel_MISresources”——“Menu”文件夹,双击Menu文件夹下的“IDR_MAINFRAME”,出现如图2所示结果
图2
4、添加功能模块,如图3所示
图3
5、在“ResourceView”选项卡,依次展开“Hotel_MISresources”——“Dialog”文件夹,右键点击“Dialog”创建对话框,如图4所示
图4
6、在每个功能模块的属性框将ID改为IDD_ABOUTBOX,编译执行结果如图5所示
图5
步骤3:
总结实验和设计经验,编写实验报告
详细代码:
//Hotel_MIS.cpp:
Definestheclassbehaviorsfortheapplication.
//
#include"stdafx.h"
#include"Hotel_MIS.h"
#include"MainFrm.h"
#include"Hotel_MISDoc.h"
#include"Hotel_MISView.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CHotel_MISApp
BEGIN_MESSAGE_MAP(CHotel_MISApp,CWinApp)
//{{AFX_MSG_MAP(CHotel_MISApp)
ON_COMMAND(ID_APP_ABOUT,OnAppAbout)
//NOTE-theClassWizardwilladdandremovemappingmacroshere.
//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!
//}}AFX_MSG_MAP
//Standardfilebaseddocumentcommands
ON_COMMAND(ID_FILE_NEW,CWinApp:
:
OnFileNew)
ON_COMMAND(ID_FILE_OPEN,CWinApp:
:
OnFileOpen)
//Standardprintsetupcommand
ON_COMMAND(ID_FILE_PRINT_SETUP,CWinApp:
:
OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CHotel_MISAppconstruction
CHotel_MISApp:
:
CHotel_MISApp()
{
//TODO:
addconstructioncodehere,
//PlaceallsignificantinitializationinInitInstance
}
/////////////////////////////////////////////////////////////////////////////
//TheoneandonlyCHotel_MISAppobject
CHotel_MISApptheApp;
/////////////////////////////////////////////////////////////////////////////
//CHotel_MISAppinitialization
BOOLCHotel_MISApp:
:
InitInstance()
{
AfxEnableControlContainer();
//Standardinitialization
//Ifyouarenotusingthesefeaturesandwishtoreducethesize
//ofyourfinalexecutable,youshouldremovefromthefollowing
//thespecificinitializationroutinesyoudonotneed.
#ifdef_AFXDLL
Enable3dControls();//CallthiswhenusingMFCinasharedDLL
#else
Enable3dControlsStatic();//CallthiswhenlinkingtoMFCstatically
#endif
//Changetheregistrykeyunderwhichoursettingsarestored.
//TODO:
Youshouldmodifythisstringtobesomethingappropriate
//suchasthenameofyourcompanyororganization.
SetRegistryKey(_T("LocalAppWizard-GeneratedApplications"));
LoadStdProfileSettings();//LoadstandardINIfileoptions(includingMRU)
//Registertheapplication'sdocumenttemplates.Documenttemplates
//serveastheconnectionbetweendocuments,framewindowsandviews.
CSingleDocTemplate*pDocTemplate;
pDocTemplate=newCSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CHotel_MISDoc),
RUNTIME_CLASS(CMainFrame),//mainSDIframewindow
RUNTIME_CLASS(CHotel_MISView));
AddDocTemplate(pDocTemplate);
//Parsecommandlineforstandardshellcommands,DDE,fileopen
CCommandLineInfocmdInfo;
ParseCommandLine(cmdInfo);
//Dispatchcommandsspecifiedonthecommandline
if(!
ProcessShellCommand(cmdInfo))
returnFALSE;
//Theoneandonlywindowhasbeeninitialized,soshowandupdateit.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
returnTRUE;
}
/////////////////////////////////////////////////////////////////////////////
//CAboutDlgdialogusedforAppAbout
classCAboutDlg:
publicCDialog
{
public:
CAboutDlg();
//DialogData
//{{AFX_DATA(CAboutDlg)
enum{IDD=IDD_ABOUTBOX};
//}}AFX_DATA
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport
//}}AFX_VIRTUAL
//Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//Nomessagehandlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg:
:
CAboutDlg():
CDialog(CAboutDlg:
:
IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
voidCAboutDlg:
:
DoDataExchange(CDataExchange*pDX)
{
CDialog:
:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//Nomessagehandlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//Appcommandtorunthedialog
voidCHotel_MISApp:
:
OnAppAbout()
{
CAboutDlgaboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
//CHotel_MISAppmessagehandlers
//Hotel_MISView.cpp:
implementationoftheCHotel_MISViewclass
//
#include"stdafx.h"
#include"Hotel_MIS.h"
#include"Hotel_MISDoc.h"
#include"Hotel_MISView.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CHotel_MISView
IMPLEMENT_DYNCREATE(CHotel_MISView,CView)
BEGIN_MESSAGE_MAP(CHotel_MISView,CView)
//{{AFX_MSG_MAP(CHotel_MISView)
//NOTE-theClassWizardwilladdandremovemappingmacroshere.
//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!
//}}AFX_MSG_MAP
//Standardprintingcommands
ON_COMMAND(ID_FILE_PRINT,CView:
:
OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT,CView:
:
OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW,CView:
:
OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CHotel_MISViewconstruction/destruction
CHotel_MISView:
:
CHotel_MISView()
{
//TODO:
addconstructioncodehere
}
CHotel_MISView:
:
~CHotel_MISView()
{
}
BOOLCHotel_MISView:
:
PreCreateWindow(CREATESTRUCT&cs)
{
//TODO:
ModifytheWindowclassorstylesherebymodifying
//theCREATESTRUCTcs
returnCView:
:
PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
//CHotel_MISViewdrawing
voidCHotel_MISView:
:
OnDraw(CDC*pDC)
{
CHotel_MISDoc*pDoc=GetDocument();
ASSERT_VALID(pDoc);
//TODO:
adddrawcodefornativedatahere
}
/////////////////////////////////////////////////////////////////////////////
//CHotel_MISViewprinting
BOOLCHotel_MISView:
:
OnPreparePrinting(CPrintInfo*pInfo)
{
//defaultpreparation
returnDoPreparePrinting(pInfo);
}
voidCHotel_MISView:
:
OnBeginPrinting(CDC*/*pDC*/,CPrintInfo*/*pInfo*/)
{
//TODO:
addextrainitializationbeforeprinting
}
voidCHotel_MISView:
:
OnEndPrinting(CDC*/*pDC*/,CPrintInfo*/*pInfo*/)
{
//TODO:
addcleanupafterprinting
}
/////////////////////////////////////////////////////////////////////////////
//CHotel_MISViewdiagnostics
#ifdef_DEBUG
voidCHotel_MISView:
:
AssertValid()const
{
CView:
:
AssertValid();
}
voidCHotel_MISView:
:
Dump(CDumpContext&dc)const
{
CView:
:
Dump(dc);
}
CHotel_MISDoc*CHotel_MISView:
:
GetDocument()//non-debugversionisinline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CHotel_MISDoc)));
return(CHotel_MISDoc*)m_pDocument;
}
#endif//_DEBUG
/////////////////////////////////////////////////////////////////////////////
//CHotel_MISViewmessagehandlers
实验总结:
通过这次实验,我对事件驱动的基本架构有所了解,并了解基于事件驱动模式的编程的基本设计方法,对WINDOWS的程序平台上的设计实现方法也有一定掌握,但仍有许多不足之处,比如在编程实现方面仍然很薄弱,我将在今后的学习中加强这方面上的练习。