![上機實驗報告源代碼_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/15/821524fe-8b95-4494-8b6f-41f6997032ed/821524fe-8b95-4494-8b6f-41f6997032ed1.gif)
![上機實驗報告源代碼_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/15/821524fe-8b95-4494-8b6f-41f6997032ed/821524fe-8b95-4494-8b6f-41f6997032ed2.gif)
![上機實驗報告源代碼_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/15/821524fe-8b95-4494-8b6f-41f6997032ed/821524fe-8b95-4494-8b6f-41f6997032ed3.gif)
![上機實驗報告源代碼_第4頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/15/821524fe-8b95-4494-8b6f-41f6997032ed/821524fe-8b95-4494-8b6f-41f6997032ed4.gif)
![上機實驗報告源代碼_第5頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/15/821524fe-8b95-4494-8b6f-41f6997032ed/821524fe-8b95-4494-8b6f-41f6997032ed5.gif)
版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、class People protected double weight,height; public void speakHello() System.out.println("yayawawa"); public void averageHeight() height=173; System.out.println("average height:"+height); public void averageWeight() weight=70; System.out.println("average weight:"+weight
2、); class ChinaPeople extends People public void speakHello() System.out.println("你好,吃飯了嗎?"); public void averageHeight() height=173.0; System.out.println("中國人的average height:"+height); public void averageWeight() weight=67.34; System.out.println("中國人的average weight:"+we
3、ight); public void chinaGongfu() System.out.println("坐如鐘,站如松,睡如弓"); class AmericanPeople extends People public void speakHello() System.out.println("How do you do"); public void averageHeight() height=188.0; System.out.println("American average height:"+height); public
4、void averageWeight() weight=80.23; System.out.println("American average weight:"+weight); public void americanBoxing() System.out.println("直拳,鉤拳"); class BeijingPeople extends ChinaPeople public void speakHello() System.out.println("您好"); public void aversageHeight() he
5、ight=167.0; System.out.println("北京人的average height:"+height); public void averageWeight() weight=68.5; System.out.println("北京人的average weight:"+weight); public void beijingOpera() System.out.println("京劇術語"); public class Example public static void main(String args) Chin
6、aPeople chinaPeople=new ChinaPeople(); AmericanPeople americaPeople=new AmericanPeople(); BeijingPeople beijingPeople=new BeijingPeople(); chinaPeople.speakHello(); americanPeople.speakHello(); beijingPeople.speakHello(); americanPeople.averageHeight(); beijingPeople.averageHeight(); chinaPeople.ave
7、rageWeight(); americanPeople.averageWeight(); beijingPeople.averageWeight(); chinaPeople.chinaGongfu(); americaPeople.americanBoxing(); beijingPeople.beijingOpera(); beijingPeople.chinaGongfu(); import java.awt.*;import java.awt.event.*;public class ComputerFrame extends Frame implements ActionListe
8、ner TextField textOne,textTwo,textResult; Button getProblem,giveAnwser; Label operatorLabel,message; Teacher teacher; ComputerFrame(String s) super(s); teacher=new Teacher(); setLayout(new FlowLayout(); textOne=new TextField(10); textTwo=new TextField(10); textResult=new TextField(10); operatorLabel
9、=new Label("+"); message=new Label("你還沒有回答呢"); getProblem=new Button("獲取題目"); giveAnwser=new Button("確認答案"); add(getProblem); add(textOne); add(operatorLabel); add(textTwo); add(new Label("="); add(textResult); add(giveAnwser); add(message); textResu
10、lt.requestFocus(); textOne.setEditable(false); textTwo.setEditable(false); getProblem.addActionListener(this); giveAnwser.addActionListener(this); textResult.addActionListener(this); setBounds(100,100,450,100); setVisible(true); validate(); addWindowListener(new WindowAdapter() public void windowClo
11、sing(WindowEvent e) System.exit(0); ); public void actionPerformed(ActionEvent e) if(e.getSource()=getProblem) int number1=teacher.giveNumberOne(100); int number2=teacher.giveNumberTwo(100); String operator=teacher.giveOperator(); textOne.setText(""+number1); textTwo.setText(""+n
12、umber2); operatorLabel.setText(operator); message.setText("請回答"); textResult.setText(null); if(e.getSource()=giveAnwser) String answer=textResult.getText(); try int result=Integer.parseInt(answer); if(teacher.getRight(result)=true) message.setText("你回答正確"); else message.setText(&
13、quot;你回答錯誤"); catch(NumberFormatException ex) message.setText("請輸入數(shù)字字符"); textResult.requestFocus(); validate(); public class Teacher int numberOne,numberTwo; String operator=" " boolean right; public int giveNumberOne(int n) numberOne=(int)(Math.random()*n)+1; return number
14、One; public int giveNumberTwo(int n) numberTwo=(int)(Math.random()*n)+1; return numberTwo; public String giveOperator() double d=Math.random(); if(d>=0.5) operator="+" else operator="-" return operator; public boolean getRight(int answer) if(operator.equals("+") if(a
15、nswer=numberOne+numberTwo) right=true; else right=false; else if(operator.equals("-") if(answer=numberOne-numberTwo) right=true; else right=false; return right; public class MainClass public static void main(String args) ComputerFrame frame; frame=new ComputerFrame("算術測試"); WordT
16、hread.javaimport java.awt.*;public class WordThread extends Thread char word; int k=19968; Label com; WordThread(Label com) =com; public void run() k=19968; while(true) word=(char)k; com.setText(""+word); try sleep(6000); catch(InterruptedException e) k+; if(k>=29968) k=19968; ThreadFra
17、me.javaimport java.awt.*;import java.awt.event.*;public class ThreadFrame extends Frame implements ActionListener Label wordLabel; Button button; TextField inputText,scoreText; WordThread giveWord; int score=0; ThreadFrame() wordLabel=new Label(" ",Label.CENTER); wordLabel.setFont(new Font
18、("",Font.BOLD,72); button=new Button("開始"); inputText=new TextField(3); scoreText=new TextField(5); scoreText.setEditable(false); giveWord=new WordThread(wordLabel); button.addActionListener(this); inputText.addActionListener(this); add(button,BorderLayout.NORTH); add(wordLabel,B
19、orderLayout.CENTER); Panel southP=new Panel(); southP.add(new Label("輸入標簽所顯示的漢字后回車:"); southP.add(inputText); southP.add(scoreText); add(southP,BorderLayout.SOUTH); setBounds(100,100,350,180); setVisible(true); validate(); addWindowListener(new WindowAdapter() public void windowClosing(Win
20、dowEvent e) System.exit(0); ); public void actionPerformed(ActionEvent e) if(e.getSource()=button) if(!(giveWord.isAlive() /giveWord調(diào)用方法isAlive() giveWord=new WordThread(wordLabel); try giveWord.start(); catch(Exception exe) else if(e.getSource()=inputText) if(inputText.getText().equals(wordLabel.ge
21、tText() score+; scoreText.setText("得分:"+score); inputText.setText(null); WordThread.javapublic class ThreadWordMainClass public static void main(String args) new ThreadFrame(); ReadZipimport java.io.*;import java.util.zip.*;public class ReadZipFile public static void main(String args) File
22、("book.zip"); File("Book"); byte b=new byte100; dir.mkdir(); try ZipInputStream in=new ZipInputStream(new (f); ZipEntry zipEntry=null; while(zipEntry=in.getNextEntry()!=null) (); out=new (file); int n=-1; System.out.println()+"的內(nèi)容:"); while(n=in.read(b,0,100)!=-1) Strin
23、g str=new String(b,0,n); System.out.println(str); out.write(b,0,n); out.close(); in.close(); catch(IOException ee) System.out.println(ee); Readimport java.awt.*;import java.awt.event.*;impor.*;import java.io.*;public class ReadURLSource public static void main(String args) new NetWin(); class NetWin
24、 extends Frame implements ActionListener,Runnable Button button; URL url; TextField text; TextArea area; byte b=new byte118; Thread thread; NetWin() text=new TextField(20); area=new TextArea(12,12); button=new Button("確定"); button.addActionListener(this); thread=new Thread(this); Panel p=n
25、ew Panel(); p.add(new Label("輸入網(wǎng)址:"); p.add(text); p.add(button); add(area,BorderLayout.CENTER); add(p,BorderLayout.NORTH); setBounds(60,60,360,300); setVisible(true); validate(); addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) System.exit(0); ); public void
26、actionPerformed(ActionEvent e) if(!(thread.isAlive() thread=new Thread(this); try thread.start(); catch(Exception ee) text.setText("我正在讀取"+url); public void run() try int n=-1; area.setText(null); String name=text.getText().trim(); url=new URL(name); String hostName= url.getHost(); int url
27、PortNumber= url.getPort(); String url.getFile(); InputStream in= url.openStream(); area.append("n主機:"+hostName+"端口:"+urlPortNumber+"包含的文件名字:"+); area.append("n文件的內(nèi)容如下:"); while(n=in.read(b)!=-1) String s=new String(b,0,n); area.append(s); catch(MalformedURLException e1) text.setText(""+e1); return; catch(IOException e1) text.setText(""+e1); return; import java.util.*;public class E
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度書畫藝術品市場代理銷售合同
- 2025年度建筑安全風險評估與監(jiān)測委托合同
- 2025年度國際知識產(chǎn)權轉(zhuǎn)讓合同樣本
- 2024-2025學年福建省福州第十中學高一上學期期中考試歷史試卷
- 2025年公共租賃場地安全協(xié)議
- 2025年合作協(xié)議訂立與實施年
- 2025年醫(yī)院護師職責合同
- 2025年農(nóng)場土地租賃合同年協(xié)議書
- 2025年TBBS項目申請報告模稿
- 2025年焦化二甲苯項目規(guī)劃申請報告模范
- 酒店長包房租賃協(xié)議書范本
- 2 找春天 公開課一等獎創(chuàng)新教學設計
- 2025年江蘇護理職業(yè)學院高職單招語文2018-2024歷年參考題庫頻考點含答案解析
- 2025年江蘇南京水務集團有限公司招聘筆試參考題庫含答案解析
- 【道法】開學第一課 課件-2024-2025學年統(tǒng)編版道德與法治七年級下冊
- 口腔門診分診流程
- 建筑工程施工安全管理課件
- 2025年春新外研版(三起)英語三年級下冊課件 Unit2第1課時Startup
- 2025年上半年畢節(jié)市威寧自治縣事業(yè)單位招考考試(443名)易考易錯模擬試題(共500題)試卷后附參考答案
- 處方點評知識培訓
- 2025年新合同管理工作計劃
評論
0/150
提交評論