计算器课程设计报告封面模板12.doc_第1页
计算器课程设计报告封面模板12.doc_第2页
计算器课程设计报告封面模板12.doc_第3页
计算器课程设计报告封面模板12.doc_第4页
计算器课程设计报告封面模板12.doc_第5页
已阅读5页,还剩19页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

肇庆学院计算机学院课程设计报告课程名称:面向对象程序设计课程设计课程设计题目:基于Winform的多功能计算器的设计与实现姓 名:陈文佳专 业:网络工程年 级:09级(1)班学 号:200924133113指导教师:白伟华2010年 12 月 25 日课程设计报告结果评定评语:评分项目分值得分课程设计报告符合规范10分类图、用例图、系统框图合理30分主要技术线路正确,功能完善30分设计报告条理清晰、重点突出20分测试报告及结果10分成绩:指导教师签字:任务下达日期:9月30日评定日期:目 录1.设计目的42.设计要求43.设计方案44.设计内容9 4.1 XXXXXXXXXXXXXXXX10 4.2 XXXXXXXXXXXXXXXX10 4.3 XXXXXXXXXXXXXXXX105.总结10参考文献101.设计目的图形界面设计,通过设计一个多功能计算器掌握图形界面的设计方法,从而检测对C+程序设计课程设计这门课的掌握情况,有助于及时查漏补缺。2.设计要求(1)利用面向对象的知识并参照Windows XP系统附件下的“科学型计算器”设计开发一个多功能的计算器;(2)不限制采用的开发平台和编程语言;(3)要求用UML描述设计过程;(4)要求用系统/程序运行时的截图描述实现的测试过程,系统的功能说明;(5)用原代码(加注释)描述主要的功能实现过程及算法;(6)提交纸质打印课程设计报告及项目工程原代码(所有人刻录在一张光碟中,两份,一份用以存档)。 3.设计方案(1)设计出计算器的基本框架。(2)把全部功能对应的按钮跟编辑框整理出来,要求大小符合规格(标上记号)。(3)实现按钮对应的功能(比如按下按钮1,在编辑框显示1)。(4)逐个添加运算符的功能。(5)修改,每设计一个功能要求都能与前面的功能相兼容。(6)完成。最终图形界面如下:4.设计内容4.1实验步骤与过程(黑体字部分)/ 1Dlg.cpp : implementation file/#include stdafx.h#include 1.h#include 1Dlg.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif#include int p=0,m,h=0,q=0; /m为余数 p,q为指数 double n0=0; double n1=1;double n2=2; double n3=3;double n4=4; double n5=5;double n6=6; double n7=7;double n8=8; double n9=9, x=1; double k=0;int j=1,n=0,R; int r,y;/执行后退操作 h判断执行的性质(加,减,乘,除)/ CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialogpublic:CAboutDlg();/ Dialog Data/AFX_DATA(CAboutDlg)enum IDD = IDD_ABOUTBOX ;/AFX_DATA/ ClassWizard generated virtual function overrides/AFX_VIRTUAL(CAboutDlg)protected:virtual void DoDataExchange(CDataExchange* pDX); / DDX/DDV support/AFX_VIRTUAL/ Implementationprotected:/AFX_MSG(CAboutDlg)/AFX_MSGDECLARE_MESSAGE_MAP();CAboutDlg:CAboutDlg() : CDialog(CAboutDlg:IDD)/AFX_DATA_INIT(CAboutDlg)/AFX_DATA_INITvoid CAboutDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CAboutDlg)/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CAboutDlg, CDialog)/AFX_MSG_MAP(CAboutDlg)/ No message handlers/AFX_MSG_MAPEND_MESSAGE_MAP()/ CMy1Dlg dialogCMy1Dlg:CMy1Dlg(CWnd* pParent /*=NULL*/): CDialog(CMy1Dlg:IDD, pParent)/AFX_DATA_INIT(CMy1Dlg)m_result = 0.0;/AFX_DATA_INIT/ Note that LoadIcon does not require a subsequent DestroyIcon in Win32m_hIcon = AfxGetApp()-LoadIcon(IDR_MAINFRAME);void CMy1Dlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CMy1Dlg)DDX_Text(pDX, IDC_EDIT1, m_result);/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CMy1Dlg, CDialog)/AFX_MSG_MAP(CMy1Dlg)ON_WM_SYSCOMMAND()ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_BN_CLICKED(IDC_BUTTON1, OnButton1)ON_BN_CLICKED(IDC_BUTTON2, OnButton2)ON_BN_CLICKED(IDC_BUTTON3, OnButton3)ON_BN_CLICKED(IDC_BUTTON4, OnButton4)ON_BN_CLICKED(IDC_BUTTON5, OnButton5)ON_BN_CLICKED(IDC_BUTTON6, OnButton6)ON_BN_CLICKED(IDC_BUTTON7, OnButton7)ON_BN_CLICKED(IDC_BUTTON8, OnButton8)ON_BN_CLICKED(IDC_BUTTON9, OnButton9)ON_BN_CLICKED(IDC_BUTTON10, OnButton10)ON_BN_CLICKED(IDC_BUTTON12, OnButton12)ON_BN_CLICKED(IDC_BUTTON11, OnButton11)ON_BN_CLICKED(IDC_BUTTON13, OnButton13)ON_BN_CLICKED(IDC_BUTTON14, OnButton14)ON_BN_CLICKED(IDC_BUTTON15, OnButton15)ON_BN_CLICKED(IDC_BUTTON16, OnButton16)ON_BN_CLICKED(IDC_BUTTON17, OnButton17)ON_BN_CLICKED(IDC_BUTTON18, OnButton18)ON_BN_CLICKED(IDC_BUTTON19, OnButton19)ON_BN_CLICKED(IDC_BUTTON20, OnButton20)ON_BN_CLICKED(IDC_BUTTON23, OnButton23)ON_BN_CLICKED(IDC_BUTTON24, OnButton24)ON_BN_CLICKED(IDC_BUTTON26, OnButton26)ON_BN_CLICKED(IDC_BUTTON25, OnButton25)ON_BN_CLICKED(IDC_BUTTON21, OnButton21)ON_BN_CLICKED(IDC_BUTTON22, OnButton22)ON_BN_CLICKED(IDC_BUTTON27, OnButton27)ON_BN_CLICKED(IDC_BUTTON28, OnButton28)ON_BN_CLICKED(IDC_BUTTON29, OnButton29)/AFX_MSG_MAPEND_MESSAGE_MAP()/ CMy1Dlg message handlersBOOL CMy1Dlg:OnInitDialog()CDialog:OnInitDialog();/ Add About. menu item to system menu./ IDM_ABOUTBOX must be in the system command range.ASSERT(IDM_ABOUTBOX & 0xFFF0) = IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX AppendMenu(MF_SEPARATOR);pSysMenu-AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);/ Set the icon for this dialog. The framework does this automatically/ when the applications main window is not a dialogSetIcon(m_hIcon, TRUE);/ Set big iconSetIcon(m_hIcon, FALSE);/ Set small icon/ TODO: Add extra initialization herereturn TRUE; / return TRUE unless you set the focus to a controlvoid CMy1Dlg:OnSysCommand(UINT nID, LPARAM lParam)if (nID & 0xFFF0) = IDM_ABOUTBOX)CAboutDlg dlgAbout;dlgAbout.DoModal();elseCDialog:OnSysCommand(nID, lParam);/ If you add a minimize button to your dialog, you will need the code below/ to draw the icon. For MFC applications using the document/view model,/ this is automatically done for you by the framework.void CMy1Dlg:OnPaint() if (IsIconic()CPaintDC dc(this); / device context for paintingSendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);/ Center icon in client rectangleint cxIcon = GetSystemMetrics(SM_CXICON);int cyIcon = GetSystemMetrics(SM_CYICON);CRect rect;GetClientRect(&rect);int x = (rect.Width() - cxIcon + 1) / 2;int y = (rect.Height() - cyIcon + 1) / 2;/ Draw the icondc.DrawIcon(x, y, m_hIcon);elseCDialog:OnPaint();/ The system calls this to obtain the cursor to display while the user drags/ the minimized window.HCURSOR CMy1Dlg:OnQueryDragIcon()return (HCURSOR) m_hIcon;void CMy1Dlg:OnButton1() / =1;/ TODO: Add your control notification handler code hereUpdateData(true);if(n!=0) m_result=0.0;if(j=0) /j=0代表执行小数点操作 j=1代表执行整数操作n1=1*0.1*pow(0.1,p);n2=2*0.1*pow(0.1,p);n3=3*0.1*pow(0.1,p);n4=4*0.1*pow(0.1,p);n5=5*0.1*pow(0.1,p);n6=6*0.1*pow(0.1,p);n7=7*0.1*pow(0.1,p);n8=8*0.1*pow(0.1,p); n9=9*0.1*pow(0.1,p);m_result=m_result+n1;p+;elsen1=m_result*10+1;m_result=n1;n=0; /避免m_result重复为1UpdateData(false);void CMy1Dlg:OnButton2() /=2;/ TODO: Add your control notification handler code hereUpdateData(true);if(n!=0)m_result=0.0;if(j=0)n1=1*0.1*pow(0.1,p);n2=2*0.1*pow(0.1,p);n3=3*0.1*pow(0.1,p);n4=4*0.1*pow(0.1,p);n5=5*0.1*pow(0.1,p);n6=6*0.1*pow(0.1,p);n7=7*0.1*pow(0.1,p);n8=8*0.1*pow(0.1,p); n9=9*0.1*pow(0.1,p);m_result=m_result+n2;p+;elsen2=m_result*10+2;m_result=n2;n=0; /避免m_result重复为2UpdateData(false);void CMy1Dlg:OnButton3() /=3;/ TODO: Add your control notification handler code hereUpdateData(true);if(n!=0)m_result=0.0;if(j=0) n1=1*0.1*pow(0.1,p);n2=2*0.1*pow(0.1,p);n3=3*0.1*pow(0.1,p);n4=4*0.1*pow(0.1,p);n5=5*0.1*pow(0.1,p);n6=6*0.1*pow(0.1,p);n7=7*0.1*pow(0.1,p);n8=8*0.1*pow(0.1,p); n9=9*0.1*pow(0.1,p);m_result=m_result+n3;p+;elsen3=m_result*10+3;m_result=n3; n=0; /避免m_result重复为3UpdateData(false);void CMy1Dlg:OnButton4() /=4;/ TODO: Add your control notification handler code hereUpdateData(true);if(n!=0)m_result=0.0;if(j=0)n1=1*0.1*pow(0.1,p);n2=2*0.1*pow(0.1,p);n3=3*0.1*pow(0.1,p);n4=4*0.1*pow(0.1,p);n5=5*0.1*pow(0.1,p);n6=6*0.1*pow(0.1,p);n7=7*0.1*pow(0.1,p);n8=8*0.1*pow(0.1,p); n9=9*0.1*pow(0.1,p);m_result=m_result+n4;p+;elsen4=m_result*10+4;m_result=n4;n=0; /避免m_result重复为4UpdateData(false);void CMy1Dlg:OnButton5() /=5;/ TODO: Add your control notification handler code hereUpdateData(true);if(n!=0)m_result=0.0;if(j=0) n1=1*0.1*pow(0.1,p);n2=2*0.1*pow(0.1,p);n3=3*0.1*pow(0.1,p);n4=4*0.1*pow(0.1,p);n5=5*0.1*pow(0.1,p);n6=6*0.1*pow(0.1,p);n7=7*0.1*pow(0.1,p);n8=8*0.1*pow(0.1,p); n9=9*0.1*pow(0.1,p);m_result=m_result+n5; p+;elsen5=m_result*10+5;m_result=n5;n=0; /避免m_result重复为5UpdateData(false);void CMy1Dlg:OnButton6() /=6;/ TODO: Add your control notification handler code hereUpdateData(true);if(n!=0) m_result=0.0;if(j=0) n1=1*0.1*pow(0.1,p);n2=2*0.1*pow(0.1,p);n3=3*0.1*pow(0.1,p);n4=4*0.1*pow(0.1,p);n5=5*0.1*pow(0.1,p);n6=6*0.1*pow(0.1,p);n7=7*0.1*pow(0.1,p);n8=8*0.1*pow(0.1,p); n9=9*0.1*pow(0.1,p);m_result=m_result+n6;p+;elsen6=m_result*10+6;m_result=n6;n=0; /避免m_result重复为6UpdateData(false);void CMy1Dlg:OnButton7() /=7;/ TODO: Add your control notification handler code hereUpdateData(true);if(n!=0)m_result=0.0;if(j=0) n1=1*0.1*pow(0.1,p);n2=2*0.1*pow(0.1,p);n3=3*0.1*pow(0.1,p);n4=4*0.1*pow(0.1,p);n5=5*0.1*pow(0.1,p);n6=6*0.1*pow(0.1,p);n7=7*0.1*pow(0.1,p);n8=8*0.1*pow(0.1,p); n9=9*0.1*pow(0.1,p);m_result=m_result+n7;p+;elsen7=m_result*10+7;m_result=n7;n=0; /避免m_result重复为7UpdateData(false);void CMy1Dlg:OnButton8() /=8;/ TODO: Add your control notification handler code hereUpdateData(true);if(n!=0)m_result=0.0;if(j=0) n1=1*0.1*pow(0.1,p);n2=2*0.1*pow(0.1,p);n3=3*0.1*pow(0.1,p);n4=4*0.1*pow(0.1,p);n5=5*0.1*pow(0.1,p);n6=6*0.1*pow(0.1,p);n7=7*0.1*pow(0.1,p);n8=8*0.1*pow(0.1,p); n9=9*0.1*pow(0.1,p);m_result=m_result+n8;p+;elsen8=m_result*10+8;m_result=n8;n=0; /避免m_result重复为8UpdateData(false);void CMy1Dlg:OnButton9() /=9;/ TODO: Add your control notification handler code hereUpdateData(true);if(n!=0)m_result=0.0;if(j=0)n1=1*0.1*pow(0.1,p);n2=2*0.1*pow(0.1,p);n3=3*0.1*pow(0.1,p);n4=4*0.1*pow(0.1,p);n5=5*0.1*pow(0.1,p);n6=6*0.1*pow(0.1,p);n7=7*0.1*pow(0.1,p);n8=8*0.1*pow(0.1,p); n9=9*0.1*pow(0.1,p);m_result=m_result+n9;p+;elsen9=m_result*10+9;m_result=n9;n=0; /避免m_result重复为9UpdateData(false);void CMy1Dlg:OnButton10() / 清零;/ TODO: Add your control notification handler code hereUpdateData(true);m_result=0.0;j=1;p=0;k=0;n=0;x=1;q=0;h=0;UpdateData(false);void CMy1Dlg:OnButton12() /加号 +/ TODO: Add your control notification handler code here UpdateData(true);/k=m_result;m_result=0.0; if(h!=1) k=0;k=k+m_result;m_result=k;h=n=1;q=p;p=0;j=1;UpdateData(false);void CMy1Dlg:OnButton11() /等于号 =/ TODO: Add your control notification handler code hereUpdateData(true);switch(h)case 1:m_result=m_result+k;k=0;if(qp)p=q;break; case 2:m_result=k-m_result;h=0; if(qp)p=q;break;case 3:m_result=m_result*x;p=p+q;x=1;break; case 4:m_result=k/m_result;h=0;break;/p=p+q;case 5:R=int(k)%int(m_result);m_result=R; break;case 6:m_result=pow(k,m_result);break;default:break;UpdateData(false);void CMy1Dlg:OnButton13() /减法 -/ TODO: Add your control notification handler code here UpdateData(true);if(h!=2)k=m_result;m_result=0; k=k-m_result; m_result=k;q=p;p=0;h=n=2;j=1;UpdateData(false);void CMy1Dlg:OnButton14() /乘法 */ TODO: Add your control notification handler code hereUpdateData(true);x=x*m_result; m_result=x;h=n=3;j=1;q=q+p;p=0;UpdateData(false);void CMy1Dlg:OnButton15() / 除号 / TODO: Add your control notification handler code hereUpdateData(true);if(h!=4)k=m_result;m_result=1;m_result=k/m_result;k=m_result;/k=m_result;h=n=4;j=1;UpdateData(false);void CMy1Dlg:OnButton16() /求余 %/ TODO: Add your control notification handler code hereUpdateData(true);k=m_result;m_result=0.0;h=n=5;j=1;UpdateData(false);void CMy1Dlg:OnButton17() / =0/ TODO: Add your control notification handler code hereUpdateData(true);if(n!=0)m_result=0.0;if(j=0) n1=1*0.1*pow(0.1,p);n2=2*0.1*pow(0.1,p);n3=3*0.1*pow(0.1,p);n4=4*0.1*pow(0.1,p);n5=5*0.1*pow(0.1,p);n6=6*0.1*pow(0.1,p);n7=7*0.1*pow(0.1,p);n8=8*0.1*pow(0.1,p); n9=9*0.1*pow(0.1,p);m_result=m_result;p+;elsen0=m_result*10+0;m_result=n0;n=0;UpdateData(false);void CMy1Dlg:OnButton18() / 小数点/ TODO: Add your control notification handler code hereUpdateData(true);j=0;n1=1;n2=2;n3=3;n4=4;n5=5;n6=6;n7=7;n8=8;n9=9;UpdateData(false);void CMy1Dlg:OnButton19() /正弦 sin/ TODO: Add your control notification handler code hereUpdateData(true);m_result=sin(m_result);UpdateData(false);void CMy1Dlg:OnButton20() /余弦 cos/ TODO: Add your control notification handler code hereUpdateData(true);m_result=cos(m_result);UpdateData(false);void CMy1Dlg:OnButton23() /后退一位/ TODO: Add your control notification handler code hereUpdateData(true);if(j=1&p=0)r=int(m_result)%10;m_result=(m_result-r)/10;elsefor(int i=0;i=100;i+)if(i=p)m=(int)(m_result*pow(10,p)%10; m_result=m_result*pow(10,p); m_result=(m_result-m)/pow(10,p); p-;if(p=0)j=1;UpdateData(false);void CMy1Dlg:OnButton24() / 正负号 +/- / TODO: Add your contro

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论