Lab整理程序設(shè)計(jì)對(duì)象與類_第1頁
Lab整理程序設(shè)計(jì)對(duì)象與類_第2頁
Lab整理程序設(shè)計(jì)對(duì)象與類_第3頁
Lab整理程序設(shè)計(jì)對(duì)象與類_第4頁
Lab整理程序設(shè)計(jì)對(duì)象與類_第5頁
已閱讀5頁,還剩25頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

題目一填空題,填充Rational.pdf中劃橫線的部分,創(chuàng)建一個(gè)名為Rational(有理數(shù))的類,用以執(zhí)行分?jǐn)?shù)運(yùn)算,通過運(yùn)行Test.java,測試Rational類的實(shí)現(xiàn)結(jié)果。 要求用整型變量表示類的private實(shí)力變量:numerator(分子)和denominator(分母)。提供構(gòu)造函數(shù)方法,使聲明類的對(duì)象時(shí)可以對(duì)他們進(jìn)行初始化。此構(gòu)造函數(shù)可按化簡形式存儲(chǔ)分?jǐn)?shù),例如,對(duì)于分?jǐn)?shù)2/4,將1存儲(chǔ)在numerator中,2存儲(chǔ)在denominator中。同時(shí)為下列運(yùn)算提供public方法: 1) 兩個(gè)Rational數(shù)相加,結(jié)果以化簡形式輸出 2) 兩個(gè)Rational數(shù)相減,結(jié)果以化簡形式輸出 3) 兩個(gè)Rational數(shù)相乘,結(jié)果以化簡形式輸出 4) 兩個(gè)Rational數(shù)相除,結(jié)果以化簡形式輸出 5) 以a/b的形式打印Rational數(shù),其中a為numerator,b為denominator 6) 以浮點(diǎn)格式打印Rational數(shù)。 最終運(yùn)行Test.java的結(jié)果為:(將Rational.java與Test.java放在同一目錄下)題目二:實(shí)現(xiàn)一個(gè)復(fù)數(shù)類(ComplexNumber),其成員變量包含實(shí)部和虛部,類成員函數(shù)要求實(shí)現(xiàn)以下方法,設(shè)置和取得實(shí)部和虛部(set和get方法),打印該復(fù)數(shù)(toString方法)。 另外實(shí)現(xiàn)靜態(tài)方法完成兩個(gè)復(fù)數(shù)的相加,相乘運(yùn)算。最后在main測試實(shí)現(xiàn)結(jié)果是否正確。復(fù)數(shù)的相加,相乘運(yùn)算函數(shù)聲明如下: public static CombNum AddComp(ComplexNumber a, ComplexNumber b) public static CombNum MulComp(ComplexNumber a, ComplexNumber b)題目三:創(chuàng)建一個(gè)簡單的類,使用這個(gè)類的對(duì)象計(jì)算長方體的表面積和體積。 要求: 1 該類維護(hù)一個(gè)長方體的長,寬,高,這些變量外部不可使用。 2 有兩個(gè)構(gòu)造函數(shù):一個(gè)無參數(shù);一個(gè)接受三個(gè)參數(shù),用之初始化長寬高。 3 提供函數(shù)接口設(shè)置長寬高屬性 4 提供函數(shù)接口計(jì)算該長方體的表面積和體積 5 在main 函數(shù)里,創(chuàng)建這個(gè)類的兩個(gè)對(duì)象,其中一個(gè)使用無參數(shù)構(gòu)造函數(shù),然后調(diào)用類的接口設(shè)置長寬高,一個(gè)使用三個(gè)參數(shù)的構(gòu)造函數(shù)。然后分別調(diào)用類的接口計(jì)算出這兩個(gè)長方體的表面積和體積。題目四完成一個(gè)數(shù)字操作類(BasicOperation),實(shí)現(xiàn)兩個(gè)數(shù)的加減乘除操作。要求實(shí)現(xiàn)的函數(shù)聲明如下: public int add(int n1, int n2) public double add(double n1, double n2) public int sub(int n1, int n2) public double sub(double n1, double n2) public int mul(int n1, int n2) public double mul(double n1, double n2) public int div(int n1, int n2) public double div(double n1, double n2) public int mod(int n1, int n2) public double mod(double n1, double n2) 另外提供了一個(gè)測試類(BPTest.java),在注釋部分說明該對(duì)象調(diào)用的是對(duì)象中的哪個(gè)方法 例如:System.out.println( 1 + 3 = +bo.add(1,3); /調(diào)用的是public int add(int n1, int n2) 需要填寫以上綠色注釋部分內(nèi)容題目五根據(jù)下面提供的UML類圖,編寫一個(gè)Rectangle類,并實(shí)現(xiàn)一個(gè)測試程序, (其中color變量為static類型,getColor()方法和setColor(String)方法也為Static類型) 要求分別以(長1,寬2),(長3,寬4)實(shí)例化兩個(gè)Rectangle對(duì)象,通過調(diào)用對(duì)象的方法輸出如圖所示的結(jié)果要求的輸出結(jié)果為:題目六創(chuàng)建一個(gè)類,類名Student。類有三個(gè)private 成員屬性:學(xué)號(hào),姓名,專業(yè)。另外要求在類里再使用一個(gè)靜態(tài)變量,此靜態(tài)變量用于生成實(shí)例對(duì)象的學(xué)號(hào)。要求在此類生成實(shí)例對(duì)象時(shí)能自動(dòng)遞增的分配學(xué)號(hào)。 具體要求: 類只能有一個(gè)構(gòu)造函數(shù),函數(shù)原型如下: public Student(String name, String major) 即不能在參數(shù)列表中傳遞學(xué)號(hào),并且保證生成的對(duì)象其學(xué)號(hào)是唯一的,并按照生成的順序遞增。 Student 類要提供以下四個(gè)方法: public static int getIDSeq() /獲得上述Student 類的靜態(tài)變量的值 public int getID() /獲得學(xué)生的學(xué)號(hào) public String getName() /獲得學(xué)生姓名 public String getMajor() /獲得學(xué)生的專業(yè) 驗(yàn)證: 提供測試用的main 函數(shù),直接放在Student 類里即可。題目七: 使用給定的MyDate類, 1.實(shí)現(xiàn)一個(gè)名為Person的類,其成員變量包括:姓,名,家庭住址,手機(jī)號(hào),郵箱,出生日期(類型為MyDate). 2.在實(shí)現(xiàn)Person類的基礎(chǔ)上,實(shí)現(xiàn)它的兩個(gè)子類Student, Employee. Student包含學(xué)生的所在年級(jí)(freshman, sophomore, junior or senior). Employee類包含給員工的公司名稱,工資,聘用日期。 3.在前兩步完成的基礎(chǔ)上,實(shí)現(xiàn)Employee的兩個(gè)子類Faculty, Staff。Faculty包含工作時(shí)間和職位等級(jí)成員變量,Staff包含職務(wù)成員變量 4對(duì)以上各類實(shí)現(xiàn)toString 方法,依次打印出它們的信息。 5. 實(shí)現(xiàn)簡單的測試 附: 1MyDate類 class MyDate public int year; public int month; public int day; public MyDate() public MyDate(int year,int month,int day) this.year = year; this.month = month; this.day = day; public String toString() return MyDate :+year+month+day; 2一個(gè)簡單的輸出例子 java Person : name:張三 address:上海 phoneNumberemail: birthday:MyDate :1987228 Student : name:張三 address:上海 phoneNumberemail: birthday:MyDate :1987228 status:1 Employee : name:張三 address:上海 phoneNumberemail: birthday:MyDate :1987228 salary:10000.0 office:fudanedu hiredDate:MyDate :2006228 Faculty : name:張三 address:上海 phoneNumberemail: birthday:MyDate :1987228 salary:10000.0office:fudanedu hiredDate:MyDate :2006228 officeHour:8 rank:1 Staff : name:張三 address:上海 phoneNumberemail: birthday:MyDate :1987228 salary:10000.0 office:fudanedu hiredDate:MyDate :2006228 title:CFO Output completed (0 sec consumed) Normal Termination題目8仿照Listing 7.13設(shè)計(jì)并實(shí)現(xiàn)一個(gè)隊(duì)列QueueOfInteger類 int add(int i) 向隊(duì)列頭中加入一個(gè)值,并返回這個(gè)值 int poll(int i) 從隊(duì)列尾取出一個(gè)值,并返回這個(gè)值 int peek() 得到隊(duì)列尾的值,但不從隊(duì)列中取出 empty(),int getSize()要求同StackOfInteger 題目九1. Design a base class Point that to represent the point in the two-dimensional plane, it contain protected field x and y to represent coordinate,two public method to get and set the x and y. 2.Design a class Circle that extend from Point to represent the circle in the two-dimensional plane,it contain the protected field r that represent radius,public method to get and set the r value and caculate the area of the circle. 3.Design a class Cylind that extend from Circle to reprensent cylind in the three-dimensional space,it contain the protected field h that represent height,public method to get and set the h value and caculate the volume. 4.Creat a circle and a cylind and display their coordinate the radius the height and the volume The output:題目十設(shè)計(jì)一個(gè)程序,輸入你的生日,輸出當(dāng)月的月歷,并標(biāo)注出你生日的那一天。要求:l 生日的輸入形式可以自己定義。l 輸出的格式要求符合下面的例子l 在具體的生日那一天前,使用大于號(hào)()標(biāo)注參照以下例子提示l 使用java.util.Calendar類,參照API相關(guān)函數(shù)說明,可能用到的方法如下:set(int year, int month, int date) Sets the values for the calendar fields YEAR, MONTH, and DAY_OF_MONTH.get(int field) Returns the value of the given calendar field.getActualMinimum(int field) Returns the minimum value that the specified calendar field could have, given the time value of this Calendar.l 以上提到方法中的參數(shù)field,可參見Calendar中的static常量:n DATEn DAY_OF_MONTHn DAY_OF_WEEK題目十一分?jǐn)?shù)四則運(yùn)算Rational用以表示一個(gè)分?jǐn)?shù),它有自己的分子和分母部分。RationalCalculate對(duì)兩個(gè)分?jǐn)?shù)進(jìn)行四則運(yùn)算完成Rational類中的方法,包括private int gcd(int m, int n)public Rational(int n, int d)public String getRationalInFraction()public String getRationalInFloat()完成RationalCalculate類中的方法public static Rational minus(Rational a, Rational b)public static Rational multiple(Rational a, Rational b)public static Rational divide(Rational a, Rational b)各方法的說明詳見代碼中的注釋題目十二Implement a class named Person and two subclasses of Person named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and e-mail address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, and date-hired. Define a class named MyDate that contains the field year, month, and day. A faculty member has office hours and a rank. A staff member has title. Override the toString method in each class to display the class name and the persons name. Test your classes.題目十二QueueOfInteger是一個(gè)整數(shù)的隊(duì)列,與Stack不同(LIFO),焦躁的元素應(yīng)當(dāng)被較早地取出(FIFO)。它應(yīng)該包括以下方法:可以參考書上7.17節(jié)StackOfInteger的實(shí)現(xiàn),但是不要使用ArrayList等Java提供的類,使用數(shù)組實(shí)現(xiàn)QueueOfInteger實(shí)現(xiàn)QueueOfInteger之后,將QueueOfInteger.java和Lab8_1.java放置同一目錄下。編譯并運(yùn)行Lab8_1.java,如果一切正確,顯示如下:你可以在Lab8_1.java中隨意增加測試或者print語句幫助你debug提示可先定義一個(gè)較小的數(shù)組,當(dāng)數(shù)組存放不下時(shí),重新初始化一個(gè)更大的數(shù)組,將原來的對(duì)象全部放到新的數(shù)組里。實(shí)現(xiàn)search方法時(shí),使用Value() = Value()來比較整數(shù),而不是integer1 = integer2。因?yàn)閕nteger1 = integer2判斷兩個(gè)變量是否指向同一個(gè)Integer實(shí)例,而Value() = Value()判斷這兩個(gè)整數(shù)的數(shù)值是否相同題目131. 實(shí)現(xiàn)一個(gè)叫List的類。你可以認(rèn)為每一個(gè)List對(duì)象是一個(gè)真正的動(dòng)態(tài)Object類型數(shù)組,它可以無限制地添加Object類型的元素,同時(shí)它有以下的方法:1) Listlist=new List();是創(chuàng)建一個(gè)List數(shù)組對(duì)象。Listlist =new List(Object temp);以上創(chuàng)建一個(gè)List數(shù)組對(duì)象,該數(shù)組對(duì)象已經(jīng)初始了一個(gè)Object數(shù)組temp.2) Objectat(Objecti);獲得數(shù)組對(duì)象在i位置上的元素,如果i大于數(shù)組長度,返回null。3) intCount;獲得數(shù)組當(dāng)前的長度。4) boolean add(Objectobject);在list數(shù)組對(duì)象的末尾添加一個(gè)元素object,這個(gè)操作可以無限制地運(yùn)行下去。5) boolean addRange(Object temp);在該數(shù)組對(duì)象的末尾自動(dòng)添加temp數(shù)組。6) boolean addAt(Objectindex,Objectvalue);在數(shù)組對(duì)象的指定位置index上插入value,后面的元素自動(dòng)后退一位,如果原始數(shù)組的Count小于index,則數(shù)組的指標(biāo)從Count到count+index-1的位置上自動(dòng)填充0。操作成功返回true,否則返回false。7) boolean removeAt(Objectindex);刪除指標(biāo)index的位置下的值,如果指標(biāo)index或者index以上位置有元素的話,則index及以上的元素自動(dòng)上升一位。操作成功返回true,否則返回false。8) boolean removeRange(Objectindex1,Objectindex2);程序刪除指標(biāo)index1和index2之間的所有元素(包括index1和index2),如果index2后面有元素的話,則index后面的元素自動(dòng)上升(index2-index1+1)位。操作成功返回true,否則返回false。特別說明,boolean方法中,用戶的輸入是invalid應(yīng)該直接返回false。2. 編寫IntList類繼承List類。該數(shù)組對(duì)象存儲(chǔ)所有int類型的元素。3. 編寫StringList類繼承List類。該數(shù)組對(duì)象存儲(chǔ)String類型的元素。但是,有新的方法:inthasSameCharacter(int index1,int index2);檢查指標(biāo)index1和index2的元素是否有相同的字符,有相同的字符返回1,否則返回-1。用戶輸入不合法返回0.4. 編寫Test類測試以上IntList類和StringList的所有方法(包括構(gòu)造方法)。Tips:(希望以下幾行代碼對(duì)大家有幫助,O(_)O)char s1=a,b,c; char s2=c,b,a; char s3=new chars1.length+s2.length; System.arraycopy(s1,0,s3,0,s1.length); System.arraycopy(s2,0,s3,s1.length,s2.length); for(int i=0;is3.length;i+)System.out.println(s3i);/測試一下s3數(shù)組里面都有哪些值題目14Explain why the underlined code is wrong. 1. (Syntax errors) public class Test private int x; public static void main(String args) new Test(); public Test(int x) this.x = x; 2. (Syntax errors) public class Test public static void main(String args) A a = new A(5.5); System.out.println(a.x); public class A private x; public void A(double x) this.x = x; 3. (Syntax errors) public class A String myStrings = new String2; myStrings0 = new String(A); public A( ) 4. (Runtime error) public class Test public static void main(String args) Object object = new Fruit(); Object object1 = (Apple)object; class Apple extends Fruit class Fruit 題目15Show the printout of the following code: 5. public class Test public static void main(String args) T t = new T(); swap(t); System.out.println(e1 = + t.e1 + e2 = + t.e2); public static void swap(T t) int temp = t.e1; t.e1 = t.e2; t.e2 = temp; class T int e1 = 1; int e2 = 2; 6. public class Test public static void main(String args) T t1 = new T(); T t2 = new T(); System.out.println(t1s i= + t1.i + and j= + t1.j); System.out.println(t2s i= + t2.i + and j= + t2.j); class T static int i = 0; / Please note that i is static int j = 0; T() i+; j+; 7. import java.util.*; public class Test public static void main(String args) Date date = new Date(); Object o = date; Date d = (Date)o; System.out.println(date = o); System.out.println(date = d); 8. class Test public static void main(String args) Count myCount = new Count(); int times = 0; for (int i = 0; i New,選擇要加入戰(zhàn)斗的機(jī)器人后雙擊或者單擊Add 按鈕即可,右邊的列表包括了所有參加戰(zhàn)斗的機(jī)器人。另外,BattleField 和Rules 選項(xiàng)卡中還能設(shè)置戰(zhàn)場大小和坦克參數(shù)。 2) 單擊 Start Battle 即可開始游戲,此時(shí)就可以看到剛才選擇的坦克之間的戰(zhàn)斗了。 4. Hello World:編寫自己的第一個(gè)機(jī)器人 1) 在 Robocode 菜單中選擇 Robot-Editor,在新建的 Robot Editor 窗口中選擇File-New-Robot,如 MyFirstRobot,接著輸入 package 名字,例如 zellux,以區(qū)別于其他名字為 MyFirstRobot 的機(jī)器人(還記得 package 的作用嗎?這在多人 開發(fā)的項(xiàng)目中尤其重要)。 2) 程序會(huì)自動(dòng)幫我們生成一段簡單的機(jī)器人代碼。讓我們來分析下這個(gè)程序: package zellux; import robocode.*; public class MyFirstRobot extends Robot public void run() while(true) ahead(100); turnGunRight(360); back(100); turnGunRight(360); public void onScannedRobot(ScannedRobotEvent e) fire(1); public void onHitByBullet(HitByBulletEvent e) turnLeft(90 - e.getBearing(); MyFirstRobot 是一個(gè)繼承了 Robot 的類,因此很多功能都已經(jīng)封裝在它的父類 Robot 中。這里我們可以感受到面向?qū)ο缶幊痰膬?yōu)點(diǎn),想想如果要不依賴于 Robot 庫寫一個(gè)類似的機(jī)器人,勢必要實(shí)現(xiàn)許多像繪制機(jī)器人、判斷是否中彈等方法。 同時(shí),面向?qū)ο蟮姆庋b性(encapsulation)把這些實(shí)現(xiàn)都隱藏了起來,我們不必知道這些細(xì)節(jié)到底是怎么實(shí)現(xiàn)的,只要知道 Robot 類中已經(jīng)有相關(guān)的代碼幫我們處理了這些問題就行。 但是后面我們會(huì)看到,Robot 類只是一個(gè)實(shí)現(xiàn)了如何移動(dòng)、如何攻擊、如何判斷敵人位置等方法的類,具體該什么時(shí)候攻擊、如何通過移動(dòng)躲避敵人的子彈、看到敵人后怎么做出反應(yīng),這就需要我們自己寫程序處理了。 MyFirstRobot 中最重要的一個(gè)方法就是 run()方法,這個(gè)方法在 Robot 類中是一個(gè)函數(shù)體為空的方法。而在 MyFirstRobot 中,這個(gè)方法的作用是不停地讓機(jī)器人前后移動(dòng)ahead(100) back(100),并不斷調(diào)整炮口 turnGunRight(360),這是一個(gè)很簡單的 AI,躲避子彈的能力很有限。 注:或許細(xì)心的同學(xué)會(huì)發(fā)現(xiàn)這四個(gè)方法是在一個(gè) while (true)語句塊中不斷重復(fù)執(zhí)行的,這似乎是一個(gè)死循環(huán),永遠(yuǎn)不會(huì)結(jié)束。但事實(shí)上 Robot 是一個(gè)實(shí)現(xiàn)了 Runnable 接口的類,在運(yùn)行機(jī)器人的時(shí)候虛擬機(jī)是通過新開一個(gè)線程來模擬機(jī)器人的運(yùn)動(dòng)的,因此這里的“死循環(huán)”不會(huì)影響其他機(jī)器人的運(yùn)動(dòng)。更多有關(guān)線程的知識(shí)推薦大家看 Core Java(Java 核心技術(shù))第二卷的第一章。 接下來是 onScannedRobot 和 onHitByBullet 方法,這兩個(gè)方法都是事件驅(qū)動(dòng)(Event-Driven)的,很像 SWING 中的 mousePressed(MouseEvent e) actionPerformed(ActionEvent e)等方法,都是在某個(gè)事件發(fā)生后才會(huì)被調(diào)用。例如在一定范圍內(nèi)前方有敵人時(shí)系統(tǒng)會(huì)調(diào)用 onScannedRobot,在 MyFirstRobot 這個(gè)例子中發(fā)現(xiàn)敵人后的處理方法只是簡單的向前發(fā)射,恐怕只對(duì)不會(huì)移動(dòng)的敵人才有效 ;-) 。 5. 學(xué)會(huì)看 API 文檔 想要自己的機(jī)器人變得更強(qiáng),就需要為它添加更詳細(xì)的戰(zhàn)斗策略。那么如何知道Robocode 這個(gè)系統(tǒng)給了我們哪些有用的方法呢? API 文檔是學(xué)習(xí)編程過程中很重要的資料,JDK 就為我們提供了詳細(xì)的文檔,里面包括了各種類及其方法的使用說明。Robocode 也一樣。 robocodejavadocindex.html 就是這份文檔的索引文件。打開后選擇左邊的Robot 類,我們可以看到這個(gè)類提供的所有方法。比如 getEnergy()方法返回當(dāng)前的生命值,以便對(duì)當(dāng)前戰(zhàn)術(shù)做出不同的決策;此外 onBulletMissed(BulletMissedEvent event)會(huì)在子彈未擊中對(duì)方時(shí)被調(diào)用。 另外我們還可以看到另一個(gè)功能更豐富的 AdvancedRobot 類,它繼承了 Robot 類,也就是說包括了 Robot 類所有 public 和 protected 方法,同時(shí)還加入了數(shù)據(jù)文件操作(可以用于記憶學(xué)習(xí))、自定義事件等高級(jí)功能。更多的東西就要大家自己去挖掘了 _。 6. 學(xué)習(xí)別人的代碼 最后,想寫出一個(gè)強(qiáng)大的機(jī)器人,還需要學(xué)習(xí)他人的代碼,這也是編程學(xué)習(xí)過程中不可或缺的一個(gè)環(huán)節(jié)。 robocoderobotssample 下就有一些簡單的機(jī)器人的源代碼,從中我們可以看到一些方法和事件具體的應(yīng)用。例如 Tracker 機(jī)器人會(huì)根據(jù)機(jī)器人的名字鎖定一個(gè)目標(biāo),然后窮追猛打;而 Interactive 機(jī)器人則可以接受玩家的控制,當(dāng)然這在比賽中是不允許的。 這些機(jī)器人以演示方法為主,AI 都比較簡單。 /Categories.jsp 可以下載到許多更高級(jí)的機(jī)器人的源代碼,其中包括更智能的目標(biāo)追蹤、躲避子彈等一些涉及算法、數(shù)學(xué)知識(shí)的功能。 What need to do write your own robot1、 Write a class extends robot class2、 Implement three functions: move, fight and scanMove is the way your robot move in battle field, which your robot is good to escape from other robots gun is depend on this.Fight is the main function how your robot fire other robotsScan is a function to use radar to discovery other robotsv 每人做一個(gè)自己認(rèn)為最好的Robot,下次課程結(jié)束時(shí),我們將根據(jù)Robot PK得分來評(píng)分(共兩次課總分20分),并請部分優(yōu)秀的同學(xué)分享自己的成功經(jīng)驗(yàn)v 上傳文件及地址(下周lab課程結(jié)束) 約定命名規(guī)范v package=fduss2007 v Robot Name=Robot + your student number work_uploadRobotcodefduss2007v Robot*.javav Robot*.class題目18Print a resume 1. Design a class named Resume to contain the following instance data fields: a) Some variables of basic information including: school(String), major(String), name(String), mobile phone number(long), mail address(String), degree (it should have only 3 status of UNDERGRADUATE, GRADUATE, or DOCTOR), and birth(String or Date). (you may also add something new) b) A inner-class called EducationExperience including: start_time(String or Date), end_time(String or Date), school(String). You can initialize your value through either Constructor or Method, but do not assign the variable directly. c) The EducationExperience class should have a variable or method to track how many times it has been invoked. (Hint: this variable should be shared by all instances) d) A string array of programming language skills like: Java, C, Perl, etc.(you can search on internet) e) A string called selfAssessment: an assessment of how this person is (like: optimistic, good at team-work, a work-alcohol, etc.) f) A method to print the resume. 2. Write a main class to invoke your Resume class. You should print the resume and the output should include the information, educational experience (and the time it has been invoked), programming language skills and personal assessment. The output should be like this: The resume could be either yourself or someone else. 題目19Fighting club 1. Design a class named Fighter to contain the following instance data fields: a) HP: the remaining health point of the fighter. HP is a random value from 150 to 300. b) Offense, defense, lucky: some parameters which will affect the result of each wave of attack. Offense, defense and lucky are all random values from 10 to 100. c) A method to get a random integer from MIN to MAX.

溫馨提示

  • 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ǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論