




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
構(gòu)造函數(shù)定義一個(gè)“點(diǎn)”(Point)類用來表示三維空間中得點(diǎn)(有三個(gè)坐標(biāo))。要求如下:可以生成具有特定坐標(biāo)的點(diǎn)對象提供可以設(shè)置三個(gè)坐標(biāo)的方法提供可以計(jì)算該“點(diǎn)”據(jù)原點(diǎn)距離平方的方法編寫程序驗(yàn)證上述三條TestPoint.javapublicclassTestPoint{ doublex; doubley; doublez; TestPoint(double_x,double_y,double_z){ x=_x; y=_y; z=_z; } voidsetx(double_x){ x=_x; } voidsetY(double_y){ y=_y; } voidsetx(double_z){ z=_z; } doublegetdistince(TestPointp){ return(x-p.x)*(x-p.x)+(y-p.y)*(y-p.y)+(z-p.z)*(z-p.z);//對于任意一個(gè)點(diǎn)都可以計(jì)算
} publicstaticvoidmain(Stringagrs[]){ TestPointp=newTestPoint(1.0,2.0,3.0); p.setx(4.0); p.sety(7.0); p.setz(6.0); System.out.println(p.x); System.out.println(p.y); System.out.println(p.z); TestPointp1=newTestPoint(1.0,4.0,3.0); System.out.println(p.getdistince(p1)); System.out.println(p.getdistince(newTestPoint(4.0,3.0,1.0))); }}方法的重寫給出程序,構(gòu)造”Teacher”類,繼承””Person”類。要求:增加“職稱(String)”屬性具有和”Student”類類似的重載構(gòu)造方法重寫”Person”類的info()方法,增加”職稱”信息TestTeacher.javaclassPerson{ privateStringname; privateStringlocation; Person(Stringname){ =name; location="beijing"; } Person(Stringname,Stringlocation){ =name; this.location=location; } publicStringinfo(){ return"name"+name+"location"+location; }}classTeacherextendsPerson{ privateStringcaptical; Teacher(Stringname,Stringcaptical){ this(name,"beijing",captical); } Teacher(Stringn,Stringl,Stringcaptical){ super(n,l); this.captical=captical; } publicStringinfo(){ ()+"captical"+captical; }}classStudentextendsPerson{ privateStringschool; Student(Stringname,Stringschool){ this(name,school,"beijing"); } Student(Stringn,Stringl,Stringschool){ super(n,l); this.school=school; } publicStringinfo(){ ()+"school"+school; }}publicclassTestTeacher{ publicstaticvoidmain(Stringagrs[]){ Personp1=newPerson("A"); Personp2=newPerson("B","shanghai"); Students1=newStudent("C","s1"); Students2=newStudent("C","shanghai","s2"); Teachert1=newTeacher("p3","professor"); System.out.println(()); System.out.println(()); System.out.println(()); System.out.println(()); System.out.println(()); }}布局管理器TestButton.javaimportjava.awt.*;publicclassTestButton{ publicstaticvoidmain(Stringargs[]){ Framef=newFrame("JavaFrame"); f.setLayout(newGridLayout(2,1)); f.setLocation(300,400); f.setSize(300,300); f.setBackground(newColor(204,204,255)); Panelp1=newPanel(newBorderLayout()); Panelp2=newPanel(newBorderLayout()); Panelp11=newPanel(newGridLayout(2,1)); Panelp21=newPanel(newGridLayout(2,1)); p1.add(newButton("Button1"),BorderLayout.WEST); p1.add(newButton("Button1"),BorderLayout.EAST); p11.add(newButton("Button11")); p11.add(newButton("Button11")); p1.add(p11,BorderLayout.CENTER); p2.add(newButton("Button2"),BorderLayout.WEST); p2.add(newButton("Button2"),BorderLayout.EAST);
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 23 女媧造人2024-2025學(xué)年新教材七年級上冊語文新教學(xué)設(shè)計(jì)(統(tǒng)編版2024)
- 第一單元第二課《特效文字制作》教學(xué)設(shè)計(jì)-2023-2024學(xué)年粵教版(2019)初中信息技術(shù)八年級上冊
- 2025年湖南省懷化市單招職業(yè)適應(yīng)性測試題庫審定版
- Unit 1 New School,New Beginnings Lesson 5 教學(xué)設(shè)計(jì) 2024-2025學(xué)年冀教版七年級英語上冊
- 《短歌行》和《歸園田居》-出與入詩人的責(zé)任與選擇比較鑒賞 教學(xué)設(shè)計(jì) 2024-2025學(xué)年統(tǒng)編版高中語文必修上冊
- 2025年紅河衛(wèi)生職業(yè)學(xué)院單招職業(yè)適應(yīng)性測試題庫必考題
- 2025年舞蹈表演合作協(xié)議書
- 3不簡單的杠桿 教學(xué)設(shè)計(jì)-2024-2025學(xué)年科學(xué)六年級上冊教科版
- 第二章電磁感應(yīng) 單元教學(xué)設(shè)計(jì)-2023-2024學(xué)年高二下學(xué)期物理人教版(2019)選擇性必修第二冊
- 2025年廣東食品藥品職業(yè)學(xué)院單招職業(yè)技能測試題庫新版
- 部編人教版語文小學(xué)六年級下冊第四單元主講教材解讀(集體備課)
- 信陽礦產(chǎn)資源概況
- EN779-2012一般通風(fēng)過濾器——過濾性能測定(中文版)
- 形位公差測量方法
- 車轍防治指導(dǎo)意見(確定稿)
- 一個(gè)近乎完美的微信引流招生方案
- 門診特殊病種審批表
- T_CEC 102.1-2016 電動(dòng)汽車充換電服務(wù)信息交換 第1部分_總則_(高清-最新版)
- 國際形式發(fā)票模板
- 山西省會(huì)計(jì)師事務(wù)所服務(wù)收費(fèi)標(biāo)準(zhǔn)(匯編)
- 陜西延長石油(集團(tuán))有限責(zé)任公司企業(yè)年金方案
評論
0/150
提交評論