c++单词学习软件课程设计报告_第1页
c++单词学习软件课程设计报告_第2页
c++单词学习软件课程设计报告_第3页
已阅读5页,还剩23页未读 继续免费阅读

下载本文档

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

文档简介

1、课程设计报告需求分析:题目:单词学习软件单词中英文录入、修改、删除管理、提供多种至少三种、例如,给出英文选中文,给出中文写英文等单词学习方法以,对出错单词能够进行查询、统计、排序。首先它是个软件要有登入用户,其次要有对单词的操作增删改,再是单词学习方法三种以上以及对学习方法过程中出错的单词能够进行存储查询、统计、排序等。概要设计:整个系统分为三大模块,先是用户登入模块供用户登入还包括了整个系统的界面的设计,这里设了一个用户类classuser(public:charusername20;charpassword20;user(charname,charmm);intfind(charname)

2、;voiduserregister();voiduserjudge();charcustom();charserver1();charserver2();friendcharcontinueif();friendintuser_long(long,char);主要有用户注册userregister()、用户判断userjudge(),第一个主菜单界面custom()、二个子菜单界面server1()server2()等成员函数;再是对单词的一系列操作增删改及额外添加的翻译模块,这里设计了一个单词类classwords(public:charenglish20;charchinese40;voi

3、dwords_get(charen,charch);voidwords_add();voidwords_delete();voidwords_revise();voidwords_translate();friendintwords_long(long,charaa);friendlongwords_seek(charch);friendintwords_long2(long,charaa);/倒数friendstructword*creat();friendvoidwritefile(structword*);主要有单词增加words_add()、单词删除words_delete()、单词修

4、改words_revise()、单词翻译words_translate()等成员函数及一些友元函数;最后一个模块是单词学习方法,这里设计了个单词游戏类classwordsgame(public:voidgame_get(charen);intgame_abc();intgame_tran();voidgame_judge();voidwrongwords_add();voidwrongwords_examine();voidwordsgame:wrongwords_search();structwrongword*wrongwords_creat();friendlongwrongwords_

5、seek(charen);friendintwords_long(long,char);friendintwrongwords_long(long,charaa);friendstructword*creat();friendvoidprint(structword*);friendintsuiji(intnum););主要有给出英文单词选中文三选一game_abc()、给出中文写英文对中文单词进行翻译game_tran()、增加错误单词wrongwords_add()、查看错词本里面全是game_tran()过程中翻译错了的单词记录在里面wrongwords_examine()、在错词本中查

6、找出错单词并统记出错次数wrongwords_search()等成员函数及一些友元供调用的函数。详细设计:描述系统各模块的实现方法,程序流程、系统界面等。重点表达自己的详细设计首先用户登入及系统界面模块通过类user来实现的,用户先通过成员函数voiduser:userregister()ofstreamllw;llw.open("f:user.txt”,ios:app);if(find(username)=1)cout<<”用户名已存在"<<endl;exit(-1);)elsellw.write(username,strlen(username)

7、;llw.put('');llw.write(password,strlen(password);llw.put('n');system("cls");cout<<"nntttt注册成功!"<<endl;)txt格式的文件user.txt来存储的,然后输入注册一个自己的号其中用户注册的账号和密码用了一个注册了的帐号和密码通过成员函数voiduser:userjudge()if(find(username)!=1)cout<<"用户名不存在!"<<endl;

8、exit(-1);)elseif(find(username)=1&&find(password)!=2)cout<<"用户密码错误!"<<endl;exit(-1);)elsesystem("cls");for(inti=10;i>=1;i-)cout<<"nntttcout<<"nnnnnttt_sleep(500);system("cls");)system("color2b");/system("cls&qu

9、ot;);/system("color2b");cout<<"nnnnnnnnttt_sleep(3000);/system("pause");欢送您使用该软件"<<'n'<<"ttt初始化中."<<i<<endl;初始化成功.!"<<endl;制作人:llw"<<endl;)来判定用户是否可以继续下面的操作,如果判定通过则跳入到第一个主菜单custom()charuser:custom()/主菜

10、单界面(charA10;charb;chari;intk=0;system("cls");cout<<"nn"<<"tt#n"<<"tt#学习方式:#n"<<"tt#1.单词操作#n"<<"tt#2.单词游戏#n"<<"tt#0.退出系统#n"<<"tt#n"<<endl;while(1)(cout<<"tt请选择学习方

11、式:"cin>>A;if(strlen(A)=1)(for(i='0'i<='2'i+)(b=i;if(b=A0)returnb;)cout<<"nttt输入有误!n"<<endl;k+;if(k>4)(system("cls");cout<<"nnttt提示:错误输入超过5次!您将被强制退出!!n"<<endl;/cout<<"tt按任意键继续"<<endl;exit(-1);

12、)有二个选项分通向二个子菜单server1()charuser:server1()CharA10;Charb;chari;intk=0;system("cls");cout<<"nn"<<"tt$n"<<"tt$<<"tt$n"功能$n"<<"tt$1.中英文的录入$n"<<"tt$2.中英文的删除$n"<<"tt$3.中英文的修改$n"<<

13、"tt$4.中英文的翻译$n"<<"tt$5.返回上一层菜单$n"<<"tt$0.退出$n"<<"tt$n"<<endl;while(1)cout<<"tt请选择操作方式:";cin>>A;if(strlen(A)=1)(for(i='0'i<='5'i+)(b=i;if(b=A0)returnb;cout<<"ntttt输入有误!n"<<en

14、dl;k+;if(k>4)(cout<<”错误输入超过5次!n"exit(-1);和server2()Charuser:server2()(charA10;charb;chari;intk=0;system("cls");cout<<"n"<<"tt$n"<<"tt$单词游戏$n"<<"tt$1.给出英文选中文$n"<<"tt$2.给出中文写英文$n"<<"tt$3.

15、查看错词本$n"<<"tt$4.查找错误单词$n"<<"tt$5.返回上一层菜单$n"<<"tt$0.退出$n"<<"tt$n"<<endl;while(1)(cout<<"tt请选择操作方式:";cin>>A;if(strlen(A)=1)(for(i='0'i<='5'i+)(b=i;if(b=A0)returnb;cout<<"ntttt

16、输入有误!n"<<endl;k+;if(k>4)(cout<<”错误输入超过5次!n"exit(-1);)分别对应着其他二个模块;server1()界面对应着单词的增删改及翻译模块通过类words来实现,有单词的增加、单词的删除、单词的修改及单词的翻译功能;单词的增加通过words_add()voidwords:words_add()(-charen20,ch40;cout<<"请输入要添加的英文单词和中文意思"<<endl;cin>>en>>ch;words_get(en,c

17、h);ofstreamllw;if(words_seek(english)=-1)(llw.open("f:ciku.txt",ios:app,0);llw.write(english,strlen(english);llw.put('');llw.write(chinese,strlen(chinese);llw.put('n');llw.close();cout<<"单词添加成功"<<endl;)elsecout<<"要添加的英文单词已存在,单词添加失败!"<

18、;<endl;)把用户输入的要添加的英文单词及中文意思存入ciku.txt文件中,单词的删除通过words_delete()voidwords:words_delete()/删除单词(-/longz=0;/intj=0;charch40;structword*head,*p1,*p2;cout<<"请输入要删除的中英文单词"<<endl;cin>>ch;head=creat();p2=p1=head;if(strcmp(p1->yw,ch)=0|strcmp(p1->zw,ch)=0)head=p1->next;w

19、hile(p1!=NULL)(if(strcmp(p1->yw,ch)=0|strcmp(p1->zw,ch)=0)(cout<<p1->yw<<":"<<p1->zw<<endl;p2->next=p1->next;cout<<"单词删除成功!"<<endl;writefile(head);break;)else(p2=p1;p1=p1->next;)if(p1=NULL)cout<<"您要删除的单词找不到!"

20、;<<endl;)把用户要删除的单词先通过调用友元函数creat()structword*creat()/创建链表并把单词放入链表中(inti=0;longz=0;charch;n=0;structword*head;word*p1=newstructword;p1->next=NULL;structword*p2;p2=p1;fstreamllw;llw.open("f:ciku.txt”,ios:in|ios:out);if(川w)cout<<"cannotopenoutput"i=words_long(z,'')

21、;llw.read(p1->yw,i);p1->ywi='0'z=z+i+1;i=words_long(z,'n');llw.seekg(z,ios:beg);llw.read(p1->zw,i);p1->zwi='0'z=z+i+1;z+;while(llw.get(ch)n+;if(n=1)head=p1;elsep2->next=p1;word*p1=newstructword;p1->next=NULL;p2->next=p1;p2=p1;i=words_long(z,'');ll

22、w.seekg(z,ios:beg);llw.read(p1->yw,i);p1->ywi='0'z=z+i+1;i=words_long(z,'n');llw.seekg(z,ios:beg);llw.read(p1->zw,i);p1->zwi='0'z=z+i+1;z+;llw.seekg(z,ios:beg);p2->next=NULL;returnhead;创建一个链表并把ciku.txt文件里的数据全存进链表里再从表里找到它删除该单词所在结点最后再通过调用writefile(structword*)voi

23、dwritefile(structword*head)structword*p;ofstreamllw("f:ciku.txt");p=head;while(p!=NULL)llw.write(p->yw,strlen(p->yw);llw.put('');llw.write(p->zw,strlen(p->zw);llw.put('n');p=p->next;deletep,head;)把新链表写入ciku.txt文件中保存来完成,单词的修改通过成员函数words_revise()voidwords:words

24、_revise()longz=0;intk=0;charen40,ch40;structword*head,*p1;cout<<"请先输入要修改的单词再输入要改为的单词”<<endl;cin>>en>>ch;/words_get(en,ch);head=creat();p1=head;while(p1!=NULL)if(strcmp(p1->yw,en)=0|strcmp(p1->zw,en)=0)if(strcmp(p1->yw,en)=0)cout<<p1->yw<<"-&g

25、t;"<<ch<<endl;strcpy(p1->yw,ch);cout<<"单词修改成功!"<<endl;)elsecout<<p1->zw<<"->"<<ch<<endl;strcpy(p1->zw,ch);cout<<"中文单词修改成功!"<<endl;)writefile(head);break;)elsep1=p1->next;)if(p1=NULL)cout<

26、<"您要修改的单词找不到!"<<endl;)把用户输入的要修改的单词通过调用友元创建链表把ciku.txt里的数据存进链表中再通过对链表的操作查找找到它并把它改为用户需要改为的单词再通过调用友元函数writefile()再把链表写回ciku.txt文件中来完成;单词翻译words_translate()intwordsgame:game_tran()inti=0,k,m;charen20;structword*p;charabc240;p=creat();m=n+1;k=suiji(m);while(p!=NULL)i+;if(i=k)strcpy(abc

27、0,p->yw);strcpy(abc1,p->zw);break;p=p->next;)elsep=p->next;)cout<<abc1<<'n'<<"请翻译"<<endl;cin>>en;/game_get(en);if(strcmp(abc0,en)=0)cout<<"翻译正确"<<endl;elsecout<<"翻译错误"<<endl;ofstreamllw("f:wr

28、ongwords.txt",ios:app);llw.write(abc0,strlen(abc0);llw.put('');llw.write(abc1,strlen(abc1);llw.put('');llw.write(en,strlen(en);llw.put('n');cout<<"错误的单词已加入到错词本中"<<endl;)deletep;return0;)有三种翻译方式:中英文单词一翻译、单独翻译中文单词和单独翻译英文单词。它根据用户的选择和输入通过调用友元words_seek(

29、)直接在文件ciku.txt中寻找用户输入的单词,再根据word_seek()的返回值输出用户需要的翻译亲实现单词的翻译等功能的;Server2()界面对应着单词游戏模块通过类wordsgame来实现,有单词选择题给出英文选中文game_abc()intwordsgame:game_abc()intk;inten;charabczw340,abcyw320;structword*p;inti=1,j=0,l=0;p=creat();n=n+1;k=suiji(n-2);while(i<=k+2)if(i<k)p=p->next;elsestrcpy(abczwj,p->

30、zw);strcpy(abcywj,p->yw);j+;p=p->next;)i+;)l=suiji(3);cout<<abcywl-1<<endl;for(intt=0;t<3;t+)cout<<t+1<<"."<<abczwt<<''cout<<"请输入你的选择"<<endl;cin>>en;if(en>=1&&en<=3)(if(en=l)cout<<"选择正

31、确"<<endl;elsecout<<"选择错误!"<<endl;)elsecout<<"输入错误"deletep;returnl;)通过调用随机函数产生随机数来输出随机数在链表结点中对应的三个单词再根据判断用户输入的正确与否来实现单词的选择,给出中文写英文game_tran()intwordsgame:game_tran()(inti=0,k,m;charen20;structword*p;charabc240;p=creat();m=n+1;k=suiji(m);while(p!=NULL)(

32、i+;if(i=k)(strcpy(abc0,p->yw);strcpy(abc1,p->zw);break;p=p->next;)elsep=p->next;)cout<<abc1<<'n'<<"请翻译"<<endl;cin>>en;/game_get(en);if(strcmp(abc0,en)=0)cout<<"翻译正确"<<endl;else(cout<<"翻译错误"<<endl;

33、ofstreamllw("f:wrongwords.txt",ios:app);llw.write(abc0,strlen(abc0);llw.put('');llw.write(abc1,strlen(abc1);llw.put('');llw.write(en,strlen(en);llw.put('n');cout<<"错误的单词已加入到错词本中"<<endl;)deletep;return0;假设否则把错误和对应通过调用随机函数来随机的读取链表结点中的中文单词再判断用户的输入

34、与否,的正确中英文单词一起存入错词本中,查看错词本game_examine()voidwordsgame:wrongwords_examine()(structwrongword*p;p=wrongwords_creat();while(p!=NULL)(cout<<p->en<<”:"<<p->ch<<""<<"wrongwords:"<<p->wrong<<endl;p=p->next;deletep;通调用wrongwords_cr

35、eat()structwrongword*wordsgame:wrongwords_creat()(-charhh;longz=0;intr=0,k=0;wrongword*p1=newstructwrongword;structwrongword*head,*p2;p2=p1;ifstreamllw("f:wrongwords.txt");if(!llw)cout<<"cannotopenthefile"<<endl;llw.seekg(z,ios:beg);k=wrongwords_long(z,'');llw

36、.read(p1->en,k);p1->enk='0'z=z+k+1;llw.seekg(z,ios:beg);k=wrongwords_long(z,'');llw.read(p1->ch,k);p1->chk='0'z=z+k+1;llw.seekg(z,ios:beg);k=wrongwords_long(z,'n');llw.read(p1->wrong,k);p1->wrongk='0'z=z+k+2;while(llw.get(hh)(r+;llw.seekg(z,i

37、os:beg);if(r=1)head=p1;wrongword*p1=newstructwrongword;p1->next=NULL;p2->next=p1;p2=p1;k=wrongwords_long(z,'');llw.read(p1->en,k);p1->enk='0'z=z+k+1;llw.seekg(z,ios:beg);k=wrongwords_long(z,'');llw.read(p1->ch,k);p1->chk='0'z=z+k+1;llw.seekg(z,ios:be

38、g);k=wrongwords_long(z,'n');llw.read(p1->wrong,k);p1->wrongk='0'z=z+k+2;llw.seekg(z,ios:beg);)p2->next=NULL;llw.close();returnhead;)创建一个链表并把错词本中的数据存入其中再读取链表中的数据输出到屏幕上,查找错误单词wrongwords_serach()voidwordsgame:wrongwords_search()charen20;charch40;charwr2020;longz=0;structwrongword*p;p=wrongwords_creat();cout<<”请输入要差找的单词"<<endl;cin>>en;while(p!=NULL)if(strcmp(p->en,en)=0)strcpy(ch,p->ch);strcpy(wrz,p->wrong);z+;)p=p->next;)cout<&l

温馨提示

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

评论

0/150

提交评论