下载
加入VIP
  • 专属下载特权
  • 现金文档折扣购买
  • VIP免费专区
  • 千万文档免费下载

上传资料

关闭

关闭

关闭

封号提示

内容

首页 java小游戏

java小游戏.doc

java小游戏

喜欢深伤的痛
2017-09-26 0人阅读 举报 0 0 暂无简介

简介:本文档为《java小游戏doc》,可适用于初中教育领域

java小游戏importjavaio*importjavautilRandompublicclassA{âÊÔÓÃÀàstaticinta=publicstaticvoidmain(Stringargs)throwsjavaioIOException{intch=RobotnewR=newRobot()âÊÔÀàRobotnewR=newRobot("LiuBL",)âÊÔÀà,ÍÔì,úÆÈËÐÕÃûΪLiuBLàºÅprint(newRgetName()"n")âÊÔgetNameºÊýSystemoutprintln(newRgetNumber()"n")âÊÔgetNumberºÊýprint(newRgetName()"n")Systemoutprintln(newRgetNumber()"n")while(a==){print("Whatdoyouwanttodon")newRtalk()newRshow()print("DoyouwanttoplayagainPressYorytocontinue,Norntoquitn")ÈâÊÔÑ,ch=Systeminread()if(ch==||ch==)a=elseif(ch==||ch==)a=else{ÒìÀíprint("WrongInputWillExit()n")break}}}staticvoidprint(Strings){ÒåstaticmainºÊýµÓÃSystemoutprintln(s)}}classRobot{ÁÄÌìúÆÈËÀàprivateStringrobotNameúÆÈËÐÕÃûprivateintrobotNumberúÆÈËàºÅWritere=newWrite()ÓÃÓÚÊäöµÎÄþµÄÀàReadsh=newRead()ÓÃÓÚÁöÎÄþµÄÀàintcountStringstr={"Hello","Hi","What'syourname","Idon'tknow","CallmeRobot","Seeyou"}úÆÈËØðÓïRobot(){ÔìºÊýrobotNumber=robotName=""count=print("Robotconstructorcallingn")âÊÔÔìºÊýµÄÔËÐÐ}Robot(Stringname,intnum){robotNumber=numrobotName=namecount=print("Robotconstructorcallingn")âÊÔÔìºÊýµÄÔËÐÐ}voidtalk()throwsjavaioIOException{ÁÄÌìÄܵÄʵÏÖintchStringsub=""print(str)for(inth=h<counth){Systemoutprint("Enterasentence:(Let'stalk,endedwithn)n")ÓÃEnterüáÊøÂÈëúÆÈËØÓwhile((ch=Systeminread())!='n'){ÁÈëÓÃÊäÈëÓïäswitch(ch){case:sub=sub"A"breakcase:sub=sub"B"breakcase:sub=sub"C"breakcase:sub=sub"D"breakcase:sub=sub"E"breakcase:sub=sub"F"breakcase:sub=sub"G"breakcase:sub=sub"H"breakcase:sub=sub"I"breakcase:sub=sub"J"breakcase:sub=sub"K"breakcase:sub=sub"L"breakcase:sub=sub"M"breakcase:sub=sub"N"breakcase:sub=sub"O"breakcase:sub=sub"P"breakcase:sub=sub"Q"breakcase:sub=sub"R"breakcase:sub=sub"S"breakcase:sub=sub"T"breakcase:sub=sub"U"breakcase:sub=sub"V"breakcase:sub=sub"W"breakcase:sub=sub"X"breakcase:sub=sub"Y"breakcase:sub=sub"Z"breakcase:sub=sub"a"breakcase:sub=sub"b"breakcase:sub=sub"c"breakcase:sub=sub"d"breakcase:sub=sub"e"breakcase:sub=sub"f"breakcase:sub=sub"g"breakcase:sub=sub"h"breakcase:sub=sub"i"breakcase:sub=sub"j"breakcase:sub=sub"k"breakcase:sub=sub"l"breakcase:sub=sub"m"breakcase:sub=sub"n"breakcase:sub=sub"o"breakcase:sub=sub"p"breakcase:sub=sub"q"breakcase:sub=sub"r"breakcase:sub=sub"s"breakcase:sub=sub"t"breakcase:sub=sub"u"breakcase:sub=sub"v"breakcase:sub=sub"w"breakcase:sub=sub"x"breakcase:sub=sub"y"breakcase:sub=sub"z"breakcase:sub=sub"'"breakcase:sub=sub""breakcase:sub=sub","breakdefault:sub=sub""break}}if(substartsWith("HELLO")||substartsWith("hello")){record(sub)Systemoutprintln("Hello")count}elseif(substartsWith("What'syourname")||substartsWith("what'syourname")){record(sub)Systemoutprintln("IRobot")count}elseif(substartsWith("Bye")||substartsWith("bye")){µÓÃÊäÈëbyeòByeÊáÊøÑ,record(sub)break}else{record(sub)intk=newRandom()nextInt()intp=kif(p<)p=pSystemoutprintln(strp)count}sub=""}}voidrecord(Stringss){ÇÂÓÃÊäÈëµÄreaddFile(ss)remainWrite()}voidshow(){ÕÊÓÃÉÏÎÊäÈëµÄ×îºóÒäsharrayW(count)shmainRead()}intgetNumber(){µØúÆÈËàºÅreturnrobotNumber}StringgetName(){µØúÆÈËÐÕÃûreturnrobotName}publicstaticvoidprint(Strings){ÒåstatictalkºÊýµÓÃSystemoutprintln(s)}}classRead{ÁȺÊýintcounter=publicvoidmainRead(){DataInputStreamdataInput=try{dataInput=newDataInputStream(newFileInputStream("c:dat"))StringData=dataInputread()Systemoutprintln(Data"")}catch(FileNotFoundExceptione){eprintStackTrace()}catch(IOExceptione){eprintStackTrace()}finally{if(dataInput!=){try{dataInputclose()}catch(IOExceptione){}}}}publicvoidarrayW(into){counter=o}}classWrite{ÐÈëºÊýStringini=""publicWrite(){}publicvoidmainWrite(){DataOutputStreamdataOutput=try{dataOutput=newDataOutputStream(newFileOutputStream("c:dat"))dataOutputwrite(ini)}catch(FileNotFoundExceptione){eprintStackTrace()}catch(IOExceptione){eprintStackTrace()}finally{if(dataOutput!=){try{dataOutputclose()}catch(IOExceptione){}}}}publicvoidaddFile(Stringli){ini=li}}wen()()"":()figureveins:textarticle""""""ab“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”“”figureveins“”“”“”“”“”character“”“”“”“”literarycompositionvirtueliterarytalentdocumentclassicsversewritingsrecordnaturalphenomenon“”achievementsincultureandeducationcivilianpostarticlesofdecreeliterarylanguagerites()()()()()formappearance()()()musictune()()studydeligentlytatto(theskin)“”()()()coverup()()decorate()()()()()()()()write()()()“”“”magnificentgorgeous()()()()()()()mildgentle()finegood()()()“”disordered

用户评价(0)

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

文档小程序码

使用微信“扫一扫”扫码寻找文档

1

打开微信

2

扫描小程序码

3

发布寻找信息

4

等待寻找结果

我知道了
评分:

/21

java小游戏

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利