Java Reference
In-Depth Information
you do with the deck of cards or a hand when playing the game.
E8. Implement and test the class of the previous exercise. You may want to hold
a bunch of cards in a Vector (see Sec. 5.3).
E9. Students in a class have received three scores on homeworks so far.
Depending on the average of these three scores, they are either passing, margin-
al, or failing. Passing is an average in the range 70..100 , marginal is an average
in the range 55..69 , and failing is an average in the range 0..54 . Design a class
whose instances represent students. A student has a name and three scores. It
should be possible to retrieve the name, the scores, and the average. It should
also be possible to see whether a student is passing, marginal, or failing. For the
latter method, introduce three constants, PASSING, MARGINAL, and FAIL-
ING, and have the function return one of them. Read Sec. 3.3.1.
E10. Implement and test the class of the previous exercise.
E11. Design a class each instance of which represents a library book, which has
a title, author, and call number.
E12. Implement and test the class of the previous exercise.
E13. Design a class each instance of which represents an entry in an address
book. It has a person's name, address (as a String ), phone number, email
address, and birthday (which could be of class Date ).
E14. Implement and test the class of the previous exercise.
E15. Design a class each instance of which is an address book. Use the class of
exercise E13 for the entries in the address book. Given an address book, one
should be able to look for an entry by name, phone number, or address. It should
be possible to delete an entry, change part of an entry, etc.
E16. Implement and test the class of the previous exercise. You may want to
maintain the collection of entries in the address book using class Vector (see
Sec. 5.3).
E17. Write a test of a class whose instances represent a time of day, i.e. it main-
tains the hour and minute. The user should be able to state whether the time
should be seen as a 12-hour or 24-hour mechanism. In the first case, method
toString method should produce a time that looks like 10:30AM or 03:16PM ; in
the second case, 10:30 or 15:16 . Note that the hour is always two digits. The
user should be able to retrieve and set the hour, and minute.
E18. Design a class like that of exercise E17 except that it also maintains the
time zone. Include just a few time zones, like GMT (Greenwich Mean Time)
EST (Eastern Standard Time) and EDT (Eastern Daylight Time).
E19. Implement and test the class of the previous exercise. How many test cases
do you need to ensure that it is correct? If you need help with handling Strings,
 
Search WWH ::




Custom Search