1 / 4

物件導向實習 08

物件導向實習 08. 97.11.25. HW Page.418 8.4.

dhowe
Download Presentation

物件導向實習 08

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 物件導向實習08 97.11.25

  2. HW Page.418 8.4 • (Rectangle Class) Create a class Rectangle. The class has attributes length and width, each of which defaults to 1. It has methods that calculate the perimeter and the area of the rectangle. It has set and get methods for both length and width. The set methods should verify that length and width are each floating-point numbers larger than 0.0 and less that 20.0. Write a program to test class Rectangle.

  3. HW Page 418 8.6 • Modify class time2 of Fig. 8.5 to include a tick method that increments the time stored in a Time2 object by one second. Provide method incrementMinute to increment the minute and method incrementHour to increment the hour. The Time2 object should always remain in a consistent state. Write a program that tests the tick method, the incrementMinute method and the incrementHour method to ensure that they work correctly. Be sure to test the following cases:

  4. HW Page 418 8.6 (cont.) • A) incrementing into the next minute. • B) incrementing into the next hour and • C) incrementing into the next day (i.e. 11:59:59 PM to 12:00:00 AM).

More Related