计算机实习设计报告杨抒含20122110392014-4-162012211208班电子工程学院1目录一、倒计时器...................................................................................................................................2二、小学生四则运算器...................................................................................................................5三、BMI计算器.............................................................................................................................26四、以自己为原型的动画.............................................................................................................32五、程序移植安卓.........................................................................................................................34六、实习总结.................................................................................................................................362一、倒计时器设计平台:QTCREATOR设计语言:C++平台优势:①可先设计图形化界面,方便新手设计简单的图形化程序,且思路清晰。②QT方便移植,集成了特定于QT的功能,如信号与槽(SIGNALS&SLOTS)图示调试器,对QT类结构可一目了然集成了QTDESIGNER可视化布局和格式构建器,只需单击一下就可生成和运行QT项目易于跨平台,为接下来的第六题程序移植做准备。程序截图(全屏)全屏在图形化界面设计,无代码。3设计流程:部分源代码#includeutimer.h#includeui_utimer.h#includeQtGui设计图形化界面,布局将图形界面控件与代码一一对应定义头文件,以及全局变量思考所需功能,定义子函数编辑子函数,实现对应功能定义新的资源文件,将提示音导入资源文件中调试,发现背景无法更改,解决成本太高。。。选择编译器,导出exe文件debug4#includeQSound//为了使用提示音,需添加QSound#includeQtWidgetsUTimer::UTimer(QWidget*parent):QWidget(parent),ui(newUi::UTimer){ui-setupUi(this);ui-lineEdit-setInputMethodHints(Qt::ImhDigitsOnly);//输入框只能输入数字,防止输入文字捣乱ui-lineEdit-setMaxLength(4);//最多输入4位m_timer=newQTimer(this);m_pause=false;ui-lcd_m-setDigitCount(1);ui-lcd_s-setDigitCount(1);ui-lcd_m_1-setDigitCount(1);ui-lcd_s_1-setDigitCount(1);ui-lcd_mid-setDigitCount(1);ui-lcd_mid-display(:);connect(m_timer,SIGNAL(timeout()),this,SLOT(subTime()));//连接信号与槽,将图形化界面导入程序,下同。connect(ui-button_start,SIGNAL(clicked()),this,SLOT(start()));connect(ui-button_pause,SIGNAL(clicked()),this,SLOT(pause()));}UTimer::~UTimer(){deleteui;deletem_timer;}voidUTimer::start(){if(m_pause){m_pause=false;}else{setTime(this-ui-lineEdit-text().toInt());}while(m_time&&!m_timer-isActive()){m_timer-start(1000);}5}voidUTimer::pause(){m_timer-stop();m_pause=true;}voidUTimer::subTime(){m_time--;showTime(m_time);voidUTimer::showTime(constunsignedinttime_ins){intm=m_time/60;//除60取整,可提取时间的分钟数ints=m_time%60;//除60取余数,可提取时间的秒数ui-lcd_m-display(m/10);//同理,取分钟的十位ui-lcd_m_1-display(m%10);//取分钟的个位ui-lcd_s-display(s/10);//取秒的十位ui-lcd_s_1-display(s%10);//取秒的个位QSound*tishiyin;//定义tishiyin的指针tishiyin=newQSound(:new/prefix1/djs.wav);//指针指向提示音的位置;将提示音文件与源文件放在同一个文件夹,可以使程序具有广泛性和移植性。if(m_time==5)tishiyin-play();//还剩5秒的时候播放提示音,起提示时间将到了的效果。}voidUTimer::setTime(constunsignedinttime){m_time=time*60;}二、小学生四则运算器设计平台:VS20136设计语言:C#平台优势:C#做图形化界面也十分方便,因为计算器要出很多题,所以WIDGETS比较多,故重复代码较多,所以采用VS2013来做程序截图78设计流程:部分源代码(FORM.CS)usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;设计图形化界面将原件导入源代码设计exam.cs为图形化的运作做好基本功能在form.cs中设计按钮功能导入背景图片等程序美化9usingSystem.Windows.Forms;usingSystem.Threading;namespaceExamination{publicpartialclassForm1:Form{Exam[]exams;intpage=0;intcount=0;intflag=0;//0:没有评分,1:已经评分publicForm1(){InitializeComponent();}privatevoidbutton1_Click(objectsender,EventArgse){page=0;count=0;intrange=0;try{count=Convert.ToInt32(textBoxCount.Text);}catch{MessageBox.Show(请正确输入试题数量!);return;}try{range=Convert.ToInt32(textBoxRange.Text);}catch{MessageBox.Show(请正确输入试题范围!);return;}//产生试题exams=newExam[count];10for(inti=0;icount;i++){exams[i]=newExam(range,true);Thread.Sleep(15);}//显示试题ShowExamList(page);button3.Enabled=false;button4.Enabled=true;groupBox1.Visible=false;textBoxA1.Focus();}privatevoidForm1_Load(objectsender,EventArgse){page=0;ClearExamList();}privatevoidShowExamList(intlPage){intendState=(lPage+1)*10;if(endState=count)endState=count;for(inti=lPage*10;iendState;i++){switch(i%10){case0:labelNo1.Text=Convert.ToString(i+1)+.;labelExam1.Text=exams[i].GetExam();labelNo1.Visible=true;labelExam1.Visible=true;textBoxA1.Text=;textBoxA1.Visible=true;break;case1:labelNo2.Text=Convert.ToString(i+1)+.;labelExam2.Text=exams[i].GetExam();11labelNo2.Visible=true;labelExam2.Visible=true;textBoxA2.Text=;textBoxA2.Visible=true;break;case2:labelNo3.Text=Convert.ToString(i+1)+.;labelExam3.Text=exams[i].GetExam();labelNo3.Visible=true;labelExam3.Visible=true;textBoxA3.Text=;textBoxA3.Visible=true;break;case3:labelNo4.Text=Convert.ToString(i+1)+.;labelExam4.Text=exams[i].GetExam();labelNo4.Visible=true;labelExam4.Visible=true;textBoxA4.Text=;textBoxA4.Visible=true;break;case4:labelNo5.Text=Convert.ToString(i+1)+.;labelExam5.Text=exams[i].GetExam();labelNo5.Visible=true;labelExam5.Visible=true;textBoxA5.Text=;textBoxA5.Visible=true;break;case5:labelNo6.Text=Convert.ToString(i+1)+.;labelExam6.Text=exams[i].GetExam();labelNo6.Visible=true;labelExam6.Visible=true;textBoxA6.Text=;textBoxA6.Visible=true;break;case6:labelNo7.Text=Convert.ToString(i+1)+.;labelExam7.Text=exams[i].GetExam();labelNo7.Visible=true;labelExam7.Visible=true;textBox