Java Reference
In-Depth Information
library. Implement the interface such that the tasks are ranked by
priority. Create a driver class whose
main
method shows these new
features of
Task
objects.
PP 7.8
Design a Java interface called
Lockable
that includes the follow-
ing methods:
setKey
,
lock
,
unlock
, and
locked
. The
setKey
,
lock
, and
unlock
methods take an integer parameter that repre-
sents the key. The
setKey
method establishes the key. The
lock
and
unlock
methods lock and unlock the object, but only if the
key passed in is correct. The
locked
method returns a boolean
that indicates whether or not the object is locked. A
Lockable
object represents an object whose regular methods are protected:
if the object is locked, the methods cannot be invoked; if it is
unlocked, they can be invoked. Redesign and implement a ver-
sion of the
Coin
class from Chapter 5 so that it is
Lockable
.
PP 7.9
Redesign and implement a version of the
Account
class from
Chapter 4 so that it is
Lockable
as defined by PP 7.8.
PP 7.10
Redesign and implement a version of the
PigLatin
program so
that it uses a GUI. Accept the sentence using a text field and dis-
play the results using a label.
PP 7.11
Modify the
IntroPanel
class of the
LayoutDemo
program so that
it uses a box layout manager. Use invisible components to put
space before and between the two labels on the panel.
PP 7.12
Modify the
QuoteOptions
program from Chapter 5 to change its
visual appearance. Present the radio buttons in a vertical column
with a surrounding border to the left of the quote label.
PP 7.13
Design and implement a program that displays a numeric key-
pad that might appear on a phone. Above the keypad buttons,
show a label that displays the numbers as they are picked. To the
right of the keypad buttons, include another button to clear the
display. Use a border layout to manage the overall presentation,
and a grid layout to manage the keypad buttons. Put a border
around the keypad buttons to group them visually, and a border
around the display.
PP 7.14
Design and implement an application that helps a pizza restau-
rant take orders. Use a tabbed pane for different categories of
food (pizza, beverages, special items). Collect information about
quantity and size. Display the cost of the order as information is
gathered. Use appropriate components for collecting the various
kinds of information. Structure the interface carefully using the
containment hierarchy and layout managers.
Search WWH ::
Custom Search