Java Reference
In-Depth Information
Implement a tax payer hierarchy that consists of a
TaxPayer
inter-
face and the classes
SinglePayer
and
MarriedPayer
that implement the
interface.
4.49
Implement a
gzip
and
gunzip
program that performs compression and
uncompression of files.
4.50
A book consists of an author, title, and ISBN number (all of which
can never change once the topic is created).
A library book is a book that also contains a due date and the current
holder of the topic, which is either a
String
representing a person who
has checked the topic out or
null
if the topic is currently not checked
out. Both the due date and holder of the topic can change over time.
A library contains library topics and supports the following
operations:
4.51
1.
Add a library book to the library.
2.
Check out a library book by specifying its ISBN number and
new holder and the due date.
3.
Determine the current holder of a library book given its ISBN
number.
a.
Write two interfaces:
Book
and
LibraryBook
that abstract the func-
tionality described above.
b.
Write a library class that includes the three methods specified. In
implementing the
Library
class, you should maintain the library
books in an
ArrayList
. You may assume that there are never any
requests to add duplicate books.
A set of classes is used to handle the different ticket types for a the-
ater. All tickets have a unique serial number that is assigned when the
ticket is constructed and a price. There are many types of tickets.
4.52
a.
Design a class hierarchy that encompasses the above three classes.
b.
Implement the
Ticket
abstract class. This class should store a serial
number as its private data. Provide an appropriate abstract method to
get the price of the ticket, provide a method that returns the serial
number, and provide an implementation of
toString
that prints the
serial number and price information. The
Ticket
class must provide a
constructor to initialize the serial number. To do so, use the following
strategy: maintain a static
ArrayList<Integer>
representing previously
assigned serial numbers. Repeatedly generate a new serial number
using a random number generator until you obtain a serial number
not already assigned.
Search WWH ::
Custom Search