論壇首頁 註冊 | 登入 | 會員 | 搜尋 | 統計 | 說明   RSS 訂閱全部版區     
   歡迎來到 YK Forum! 自由SAY | 開口中 | 祈願池 | 宣傳中心 | Flash遊戲 | 寵物中心 | 虛擬形像 | 勳章中心   



 
 
標題: 有冇人識程式呀!!!sos~~~~~
May/se7en
初級會員
Rank: 1


UID 16441
積分 8
經驗 3
YK幣 105
帖子 1
精華 0
註冊 2008-9-17
用戶註冊天數 5718
用戶失蹤天數 5708
性別 女仔
狀態 離線
  正常字體
發表於 2008-9-17 12:25 PM  資料 文集 短消息 
有冇人識程式呀!!!sos~~~~~

(c) The following is about creating a class Car and testing it. In every part, compile the class and correct
any syntax errors until there are no more compilation error messages. Note that you should indent your
programs properly, which is done by professionals, for all TMA answers. Otherwise marks will be
deducted. If you have no personal preference, indent four spaces for each level. See p.17 of Unit 4 and
p.37-38 of our set book (by KN King) for details.
(i) Create a class Car with the attributes brand, maximumSpeed, and price. The attributes are used
to store the brand, maximum speed (as an integer) and price of the car respectively. Choose
suitable types for them. You can copy the class TicketCounter on p.9 of the unit and modify the
content, or you can download a skeleton from the same Web page this file is downloaded. Save it
under an appropriate file name. Copy the content of the file and the compilation output
showing no errors as the answers to this part. No screen dump is recommended to minimize the file
size.
(ii) Create another class TestCar in a separate file with a method main() to test the class Car. You
can copy the class TestCounter on p.31-32 and modify the content or you can download a
skeleton from the same Web page this file is downloaded. In main(), create a Car object aCar
and print the message "An object aCar of class Car has been created". Compile the class,
correct any error and run the program. Copy the content of the file and the output showing the
message as the answers to this part.
(iii) Add a method setMaximumSpeed() to the Car class with appropriate parameter(s) and return
type to set the maximum speed of the car. Copy the content of the method and the compilation
output showing no errors as the answers to this part.
(iv) Add another method getBrand() to the Car class with appropriate parameter(s) and return type
to get the brand of the car. Copy the content of the method and the compilation output showing no
errors as the answers to this part. You should create other setter/getter methods in your class file
but no marks are allocated for them since they are similar to the ones here and in part (iii).
(v) Write another method increasePrice() of the Car class with appropriate parameter(s) and
return type to increase the price of the car. Copy the content of the method and the compilation
output showing no errors as the answers to this part.
(vi) In the class TestCar, add the following before the end of main():
_ set the maximum speed of the car to 100 km using the method setMaximumSpeed();
_ set the price of the car to $300000 using the method setPrice();
_ increase the price by 50000 using the method increasePrice();
_ print the maximum speed of the car and its new price by getting them first using the methods
getMaximumSpeed() and getPrice();
Run the program. Copy the content of the class and the output as the answers to this part.




真喺1個頭2個大,究竟成個程式喺點ga

救命ga,大家幫幫手喇



YK Forum © All rights reserved. www.eyankit.com 贊助網站 頂部
 



當前時區 GMT+8, 現在時間是 2024-5-14 05:42 PM
Copyright © 2006- YK Forum All rights reserved.

Powered by Discuz!    在線率統計 Powered by Discuz! © 2001- Comsenz Inc. Designed by YK Forum.
Processed in 0.007345 second(s), 7 queries, Gzip enabled.

[Clear cookies] Contact us 聯繫我們 - Archiver 文字版 - WAP 手機版