計(jì)算機(jī)應(yīng)用技術(shù)java課件實(shí)驗(yàn)報(bào)告_第1頁
計(jì)算機(jī)應(yīng)用技術(shù)java課件實(shí)驗(yàn)報(bào)告_第2頁
計(jì)算機(jī)應(yīng)用技術(shù)java課件實(shí)驗(yàn)報(bào)告_第3頁
計(jì)算機(jī)應(yīng)用技術(shù)java課件實(shí)驗(yàn)報(bào)告_第4頁
計(jì)算機(jī)應(yīng)用技術(shù)java課件實(shí)驗(yàn)報(bào)告_第5頁
已閱讀5頁,還剩2頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論