Java Reference
In-Depth Information
Hint: One way to do this would be to shuffle the order of the tracks in the list—or, perhaps
better, a copy of the list—and then play through from start to finish. Another way would be to
make a copy of the list and then repeatedly choose a random track from the list, play it, and
remove it from the list until the list is empty. Try to implement one of these approaches. If you
try the first, how easy is it to shuffle the list so that it is genuinely in a new random order? Are
there any library methods that could help with this?
4.14
Another example: an auction system
In this section, we will follow up some of the new ideas we have introduced in this chapter by
looking at them again in a different context.
The auction project models part of the operation of an online auction system. The idea is that an auc-
tion consists of a set of items offered for sale. These items are called “lots,” and each is assigned a
unique lot number by the program. A person can try to buy a lot they want by bidding an amount of
money for it. Our auctions are slightly different from other auctions because ours offer all lots for a
limited period. 3 At the end of that period, the auction is closed. At the close of the auction, the person
who bid the highest amount for a lot is considered to have bought it. Any lots for which there are no
bids remain unsold at the close. Unsold lots might be offered in a later auction, for instance.
Figure 4.6
The class structure
of the auction project
3 For the sake of simplicity, the time-limit aspects of auctions are not implemented within the classes we
are considering here.
 
 
Search WWH ::




Custom Search