




已閱讀5頁,還剩35頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
學(xué) 生 實(shí) 驗(yàn) 報(bào) 告 冊(理工類)課程名稱:JAVA程序設(shè)計(jì)實(shí)驗(yàn)專業(yè)班級:M11計(jì)算機(jī)科學(xué)與技術(shù)II 學(xué)生學(xué)號: 1121117031 學(xué)生姓名: 趙慧 所屬院部: 龍?bào)磳W(xué)院 指導(dǎo)教師: 董軍 20 13 20 14 學(xué)年 第 二 學(xué)期 金陵科技學(xué)院教務(wù)處制實(shí)驗(yàn)報(bào)告書寫要求實(shí)驗(yàn)報(bào)告原則上要求學(xué)生手寫,要求書寫工整。若因課程特點(diǎn)需打印的,標(biāo)題采用四號黑體,正文采用小四號宋體,單倍行距。紙張一律采用A4的紙張。實(shí)驗(yàn)報(bào)告書寫說明實(shí)驗(yàn)報(bào)告中實(shí)驗(yàn)?zāi)康暮鸵?、?shí)驗(yàn)儀器和設(shè)備、實(shí)驗(yàn)內(nèi)容與過程、實(shí)驗(yàn)結(jié)果與分析這四項(xiàng)內(nèi)容為必需項(xiàng)。教師可根據(jù)學(xué)科特點(diǎn)和實(shí)驗(yàn)具體要求增加項(xiàng)目。填寫注意事項(xiàng)(1)細(xì)致觀察,及時(shí)、準(zhǔn)確、如實(shí)記錄。(2)準(zhǔn)確說明,層次清晰。(3)盡量采用專用術(shù)語來說明事物。(4)外文、符號、公式要準(zhǔn)確,應(yīng)使用統(tǒng)一規(guī)定的名詞和符號。(5)應(yīng)獨(dú)立完成實(shí)驗(yàn)報(bào)告的書寫,嚴(yán)禁抄襲、復(fù)印,一經(jīng)發(fā)現(xiàn),以零分論處。實(shí)驗(yàn)報(bào)告批改說明實(shí)驗(yàn)報(bào)告的批改要及時(shí)、認(rèn)真、仔細(xì),一律用紅色筆批改。實(shí)驗(yàn)報(bào)告的批改成績采用五級記分制或百分制,按金陵科技學(xué)院課堂教學(xué)實(shí)施細(xì)則中作業(yè)批閱成績評定要求執(zhí)行。實(shí)驗(yàn)報(bào)告裝訂要求實(shí)驗(yàn)批改完畢后,任課老師將每門課程的每個(gè)實(shí)驗(yàn)項(xiàng)目的實(shí)驗(yàn)報(bào)告以自然班為單位、按學(xué)號升序排列,裝訂成冊,并附上一份該門課程的實(shí)驗(yàn)大綱。實(shí)驗(yàn)項(xiàng)目名稱: 面向?qū)ο缶幊虒?shí)驗(yàn) 實(shí)驗(yàn)學(xué)時(shí): 8 同組學(xué)生姓名: 實(shí)驗(yàn)地點(diǎn): 1414 實(shí)驗(yàn)日期: 3.28 4.4 實(shí)驗(yàn)成績: 批改教師: 批改時(shí)間: 實(shí)驗(yàn)1 面向?qū)ο缶幊虒?shí)驗(yàn)一、實(shí)驗(yàn)?zāi)康暮鸵螅?)理解Java概念、掌握J(rèn)DK環(huán)境配置(2)熟悉Java開發(fā)過程(3)掌握J(rèn)ava面向?qū)ο缶幊袒A(chǔ):封裝、繼承、多態(tài)(4)掌握J(rèn)ava接口編程,理解開發(fā)模式二、實(shí)驗(yàn)儀器和設(shè)備奔騰以上個(gè)人計(jì)算機(jī), windows操作系統(tǒng)。配置好JDK環(huán)境,安裝集成開發(fā)環(huán)境(Eclipse)三、實(shí)驗(yàn)內(nèi)容與過程1、JDK環(huán)境配置2、面向?qū)ο蟮姆庋b性范例:設(shè)計(jì)一個(gè)表示學(xué)生的類,里面有學(xué)生的三項(xiàng)成績:計(jì)算機(jī)成績、數(shù)學(xué)成績、英語成績。要求可以求總分、平均分、最高分、最低分,并且可以輸出一個(gè)學(xué)生的完整信息。 代碼如下:class Studentprivate String name ;private int age ;private float english ;private float computer ;private float math ;public Student()public Student(String n,int a,float e,float c,float m)this.setName(n) ;this.setAge(a) ;this.setEnglish(e) ;this.setComputer(c) ;this.setMath(m) ;public float sum()return english + computer + math ;public float avg()return this.sum() / 3 ;public float max()float max = computermath?computer:math ;max = maxenglish?max:english ;return max ;public float min()float min = computermath?computer:math ;min = min0)this.temp = new intlen ;/ 此時(shí)大小由外部決定elsethis.temp = new int1 ;/ 至少開辟一個(gè)空間public boolean add(int i)/ 加入數(shù)據(jù)操作if(this.footthis.temp.length)/ 還有空位this.tempthis.foot = i ;/ 加入內(nèi)容this.foot+ ;/ 改變長度return true ;/ 加入成功返回trueelsereturn false ;/ 加入失敗public int getArray()/ 返回全部的數(shù)組return this.temp ;class SortArray extends Arraypublic SortArray(int len)super(len) ;public int getArray()java.util.Arrays.sort(super.getArray() ;/ 排序操作return super.getArray() ;/ 返回的是排序后的內(nèi)容class ReverseArray extends Arraypublic ReverseArray(int len)super(len) ;public int getArray()int rt = new intsuper.getArray().length ;/ 根據(jù)大小開辟新數(shù)組int count = rt.length-1 ;for(int x=0;xsuper.getArray().length;x+)rtcount = super.getArray()x ;count- ;return rt ;public class ArrayDemopublic static void main(String args)ReverseArray arr = new ReverseArray(6) ;System.out.println(arr.add(3) ;System.out.println(arr.add(23) ;System.out.println(arr.add(1) ;System.out.println(arr.add(5) ;System.out.println(arr.add(6) ;System.out.println(arr.add(8) ;System.out.println(arr.add(11) ;System.out.println(arr.add(16) ;print(arr.getArray() ;public static void print(int i)for(int x=0;xi.length;x+)System.out.print(ix + 、) ;對照范例寫出如下題目:(1).創(chuàng)建GrandFather類,其中包括a)屬性:姓名(name),年齡(age)b)方法getGrandFather():顯示爺爺?shù)男畔)構(gòu)造方法:給爺爺?shù)男彰?,年齡賦值(2).創(chuàng)建Father類,繼承Grandfather類a)屬性:除了繼承爺爺?shù)膶傩砸酝?,還要增加自己的屬性:“職業(yè)”(occupation)b)構(gòu)造方法:顯式調(diào)用父類的構(gòu)造方法,為Father類的姓名和年齡賦初始值。再為職業(yè)輸入初始值。c) 方法getFather(): 顯示父親的相關(guān)信息(3). 創(chuàng)建ClassMain()類,定義main()方法,構(gòu)造GrandFather類的對象和Father類的對象,并分別顯示詳細(xì)信息。4、面向?qū)ο蠖鄳B(tài)性范例:計(jì)算柱體的體積。柱體體積計(jì)算公式是:底部面積乘以高度柱體底部分為 圓形和矩形要求:通過抽象類和多態(tài)實(shí)現(xiàn)package cn.jit.demo;abstract class Bottom /父類抽象類 底部public abstract double calculatorArea();class CircleBottom extends Bottom /圓形底/* * 半徑 */private double radius;Overridepublic double calculatorArea() return Math.PI * radius * radius;public double getRadius() return radius;public void setRadius(double radius) this.radius = radius;public CircleBottom(double radius) super();this.radius = radius;class SquareBottom extends Bottom /矩形底private double sideA;private double sideB;public double getSideA() return sideA;public void setSideA(double sideA) this.sideA = sideA;public double getSideB() return sideB;public void setSideB(double sideB) this.sideB = sideB;Overridepublic double calculatorArea() return sideA * sideB;public SquareBottom(double sideA, double sideB) super();this.sideA = sideA;this.sideB = sideB;class ZhuTi /柱體類,完成形狀的拼裝/* * 底 */private Bottom bottom;/* * 高 */private double height;/* * 計(jì)算體積 * return */public double calculatorVolumn()return bottom.calculatorArea() * height;public ZhuTi(Bottom bottom, double height) super();this.bottom = bottom;this.height = height;public Bottom getBottom() return bottom;public void setBottom(Bottom bottom) this.bottom = bottom;public double getHeight() return height;public void setHeight(double height) this.height = height;public void changeBottom(Bottom bottom)this.bottom = bottom;public class VolumnTest /測試類public static void main(String args) Bottom bottom = new CircleBottom(1.0);double height = 1.0;ZhuTi zhuTi = new ZhuTi(bottom,height);double result = zhuTi.calculatorVolumn();System.out.println(圓柱體的體積是: + result);bottom = new SquareBottom(1.0,1.0);zhuTi.changeBottom(bottom);result = zhuTi.calculatorVolumn();System.out.println(立方體的體積是: + result);范例:接口和多態(tài)的應(yīng)用,例如:電腦上實(shí)現(xiàn)了USB接口,U盤,打印機(jī)等等也都實(shí)現(xiàn)了此標(biāo)準(zhǔn)。interface USBpublic void start() ;/ 開始工作public void stop() ;/ 結(jié)束工作class Computerpublic static void plugin(USB usb)usb.start() ;usb.stop() ;class Flash implements USBpublic void start()System.out.println(U盤開始工作。) ;public void stop()System.out.println(U盤停止工作。) ;class Print implements USBpublic void start()System.out.println(打印機(jī)開始工作。) ;public void stop()System.out.println(打印機(jī)停止工作。) ;public class InterPolDemo02public static void main(String args)Computer.plugin(new Flash() ;Computer.plugin(new Print() ;對照范例,寫出以下程序:(1) 樂器(Instrument)的標(biāo)準(zhǔn)為彈奏(play),而樂器類型分為:鋼琴(Piano)和小提琴(Violin),各種樂器的彈奏方法各不同。編寫代碼實(shí)現(xiàn)不同樂器的彈奏。(2) 計(jì)算機(jī)模擬四、實(shí)驗(yàn)結(jié)果與分析(程序運(yùn)行結(jié)果及其分析)2.(3)class Circle private int radius; public Circle(int r) this.setRadius(r); public void setRadius(int r) radius=r; public int getRadius() return radius; public double printArea() return 3.14*radius*radius; public double printChang() return 2*3.14*radius; public class TestCircle public static void main(String args) Circle c1=new Circle(6); System.out.println(面積為+c1.printArea(); System.out.println(周長為+c1.printChang(); 3.class GrandFatherprivate String name;private int age;public GrandFather(String name,int age)this.setName(name);this.setAge(age);public void setName(String name)=name;public void setAge(int age)this.age=age;public String getName()return name;public int getAge()return age;public String getGrandFather()return 爺爺?shù)男彰?getName()+ +年齡:+getAge();class Father extends GrandFatherprivate String occupation;public Father(String name,int age,String occupation)super(name,age);this.setOccupation(occupation);public void setOccupation(String occupation)this.occupation=occupation;public String getOccupation()return occupation;public String getFather()return 爸爸的姓名:+getName()+ +年齡:+getAge()+ +職業(yè):+getOccupation();public class ClassMain /* * param args */public static void main(String args) / TODO Auto-generated method stubGrandFather gf=new GrandFather(wuzongyao,78);System.out.println(gf.getGrandFather();Father f=new Father(wushengguang,48,工人);System.out.println(f.getFather();4.(1)abstract class Instrumentabstract void play();class Piano extends Instrumentpublic void play()System.out.println(鋼琴是彈的!不是拉的);class Violin extends Instrumentpublic void play()System.out.println(小提琴是拉的!不是彈得);public class Test /* * param args */public static void main(String args) / TODO Auto-generated method stubInstrument p=new Piano();p.play();Instrument v=new Violin();v.play();(2)interface VideoCardvoid videoRunning();void videoClosing();interface Cpuvoid cpuRunning();void cpuClosing();class IntelCpu implements Cpupublic IntelCpu()System.out.println(Make an Intels CPU);public void cpuRunning()System.out.println(Intels CPU is Working.);public void cpuClosing()System.out.println(Intels CPU is Closing.);class DmengVideoCard implements VideoCardpublic DmengVideoCard()System.out.println(Make a DmengVideoCards VideoCard);public void videoRunning()System.out.println(Dmengs VideoCard is Working.);public void videoClosing()System.out.println(Dmengs VideoCard is Closing.);class Mainboardprivate IntelCpu cpu;private DmengVideoCard videocard;public Mainboard(IntelCpu cpu,DmengVideoCard videocard)this.cpu=cpu;this.videocard=videocard;public void run()cpu.cpuRunning();videocard.videoRunning();System.out.println(Mainboard is running.);public void close()cpu.cpuClosing();videocard.videoClosing();System.out.println(Mainboard is closing.);public class Computer public static void openPC() System.out.println(開機(jī)了。);public static void closePC() System.out.println(關(guān)機(jī)了。);public static void main(String args) Mainboard m=new Mainboard(new IntelCpu(),new DmengVideoCard();openPC();m.run();closePC();m.close();五、實(shí)驗(yàn)體會(huì)本次實(shí)驗(yàn)是關(guān)于JAVA的基礎(chǔ)知識的檢驗(yàn),基礎(chǔ)知識是整個(gè)java學(xué)習(xí)中最重要的,對以后的學(xué)習(xí)來說,這是個(gè)臺階。通過此次實(shí)驗(yàn),我對Java有了更進(jìn)一步的了解,特別是理論聯(lián)系實(shí)際。對學(xué)習(xí)Java幫助很大。也使我對Java產(chǎn)生了深厚的情趣,我會(huì)更加努力學(xué)習(xí)Java。 實(shí)驗(yàn)項(xiàng)目名稱: 類集 實(shí)驗(yàn)學(xué)時(shí): 4 同組學(xué)生姓名: 實(shí)驗(yàn)地點(diǎn): 1414 實(shí)驗(yàn)日期: 4.11 4.18 實(shí)驗(yàn)成績: 批改教師: 批改時(shí)間: 實(shí)驗(yàn)2 類集一、實(shí)驗(yàn)?zāi)康暮鸵螅?)理解類集概念(2)熟悉Collection接口、List接口、Set接口和Map接口(3)掌握ArrayList類、HashSet類和TreeSet類(4)理解TreeMap、HashMap二、實(shí)驗(yàn)儀器和設(shè)備奔騰以上個(gè)人計(jì)算機(jī), windows操作系統(tǒng)。配置好JDK環(huán)境,安裝集成開發(fā)環(huán)境(Eclipse)三、實(shí)驗(yàn)內(nèi)容與過程1、類集應(yīng)用范例:實(shí)現(xiàn)一個(gè)超市管理系統(tǒng),要求可以添加貨物,刪除貨物和查詢貨物:。 代碼如下:public interface Goods public String getName(); / 得到商品名稱public int getCount(); / 得到商品數(shù)量public float getPrice(); / 得到商品價(jià)格 public class Book implements Goods private String name;private int count;private float price;public Book() public Book(String name, int count, float price) = name;this.count = count;this.price = price;public String getName() return name;public void setName(String name) = name;public int getCount() return count;public void setCount(int count) this.count = count;public float getPrice() return price;public void setPrice(float price) this.price = price;public boolean equals(Object obj) if (this = obj) return true;if (!(obj instanceof Book) return false;Book b = (Book) obj;if (.equals() & b.count = this.count& b.price = this.price) return true; else return false;public int hashCode() return .hashCode() + new Integer(this.count).hashCode()+ new Float(this.price).hashCode();public String toString() return 書名: + + ;書的價(jià)格: + this.price + ;書的數(shù)量:+ this.count;import java.util.ArrayList;import java.util.Iterator;import java.util.List;public class SuperMarket private List allGoods;public SuperMarket() this.allGoods = new ArrayList();public void add(Goods goods) this.allGoods.add(goods);public void remove(Goods goods) this.allGoods.remove(goods);public List search(String keyWord) List temp = new ArrayList();Iterator iter = this.allGoods.iterator();while (iter.hasNext() Goods g = iter.next();if (g.getName().indexOf(keyWord) != -1) temp.add(g);return temp;public List getAllGoods() return this.allGoods;import java.util.Iterator;import java.util.List;public class Test public static void main(String args) SuperMarket mak = new SuperMarket();mak.add(new Book(Java, 2, 30.9f);mak.add(new Book(C+, 3, 10.9f);mak.add(new Book(JSP, 5, 80.9f);print(mak.search(J) ;mak.remove(new Book(Java, 2, 30.9f) ;print(mak.search(J) ;public static void print(List all) Iterator iter = all.iterator();while (iter.hasNext() System.out.println(iter.next();對照范例寫出如下題目:(1)寵物商店,要求可以添加、刪除和查找寵物(2)實(shí)現(xiàn)以下兩個(gè)關(guān)系A(chǔ)、一個(gè)學(xué)??梢杂卸鄠€(gè)學(xué)生,所有學(xué)生屬于一個(gè)學(xué)校B、一門課程可以有多個(gè)學(xué)生選,一個(gè)學(xué)生可以選多門課程四、實(shí)驗(yàn)結(jié)果與分析(程序運(yùn)行結(jié)果及其分析)(1)interface Petpublic String getName(); / 得到商品名稱public String getColor(); / 得到商品數(shù)量public float getPrice();public class Dog implements Pet private String name;private String color;private float price;public Dog() public Dog(String name, String color, float price) = name;this.color = color;this.price = price;public String getName() return name;public void setName(String name) = name;public String getColor() return color;public void setColor(String color) this.color = color;public float getPrice() return price;public void setPrice(float price) this.price = price;public boolean equals(Object obj) if (this = obj) return true;if (!(obj instanceof Dog) return false;Dog d = (Dog) obj;if (.equals() & d.color = this.color& d.price = this.price) return true; else return false;public int hashCode() return .hashCode() + new Integer(this.color).hashCode()+ new Float(this.price).hashCode();public String toString() return 狗的品種: + + ;狗的價(jià)格: + this.price + ;狗的顏色:+ this.color;import java.util.ArrayList;import java.util.Iterator;import java.util.List;public class PetSupermarket private List allpets;public PetSupermarket() this.allpets = new ArrayList();public void add(Pet pet) this.allpets.add(pet);public void remove(Pet pet) this.allpets.remove(pet);public List search(String keyWord) List temp = new ArrayList();Iterator iter = this.allpets.iterator();while (iter.hasNext() Pet p = iter.next();if (p.getName().indexOf(keyWord) != -1) temp.add(p);return temp;public List getAllpets() return this.allpets;import java.util.Iterator;import java.util.List;public class Testp public static void main(String args) PetSupermarket mak = new PetSupermarket();mak.add(new Dog(牧羊犬, 黑色, 5000);mak.add(new Dog(中華田園犬, 黑色, 200);mak.add(new Dog(藏獒, 褐色, 50000);print(mak.search(牧) ;mak.remove(new Dog(藏獒, 褐色, 50000) ;print(mak.search(中) ;public static void print(List all) Iterator iter = all.iterator();while (iter.hasNe
溫馨提示
- 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)僅提供信息存儲空間,僅對用戶上傳內(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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 農(nóng)業(yè)產(chǎn)值與種植面積對比表
- 年度營銷計(jì)劃數(shù)據(jù)對比表
- 建筑行業(yè)勞務(wù)分包與施工管理協(xié)議
- 企業(yè)智能辦公系統(tǒng)開發(fā)合作協(xié)議
- 合作推廣市場營銷合作協(xié)議
- 課程表和活動(dòng)安排表
- 日常辦公管理規(guī)章制度匯編
- 空調(diào)安裝工程總包合同
- 高中學(xué)生物理競賽準(zhǔn)備故事征文
- 科學(xué)啟蒙故事征文
- (參考)食品加工操作流程圖
- 初中英語教學(xué)設(shè)計(jì)Its-time-to-watch-a-cartoon
- 2023高中物理步步高大一輪 第十章 第1講 磁場及其對電流的作用
- 空分設(shè)備安全培訓(xùn)課件
- Adobe-Illustrator-(Ai)基礎(chǔ)教程
- 沒頭腦和不高興-竇桂梅.精選優(yōu)秀PPT課件
- 造粒塔外壁清洗施工方案
- 鋼棧橋計(jì)算書(excel版)
- 中醫(yī)診斷學(xué)第七章第二節(jié)六經(jīng)辨證
- 租賃合同審批表
- 數(shù)據(jù)庫及其應(yīng)用-重點(diǎn)復(fù)習(xí)資料.代碼02120
評論
0/150
提交評論