Java Reference
In-Depth Information
airline name, flight number, and the flight's origin and destination
cities. Define the
Flight
constructor to accept and initialize all
instance data. Include getter and setter methods for all instance data.
Include a
toString
method that returns a one-line description of
the flight. Create a driver class called
FlightTest
, whose
main
method instantiates and updates several
Flight
objects.
PP 4.7 Design and implement a class called
Bulb
that represents a light
bulb that can be turned on and off. Create a driver class called
Lights
whose
main
method instantiates and turns on some
Bulb
objects.
PP 4.8 Using the
Die
class defined in this chapter, design and implement
a class called
PairOfDice
, composed of two
Die
objects. Include
methods to set and get the individual die values, a method to roll
the dice, and a method that returns the current sum of the two
die values. Create a driver class called
RollingDice2
to instanti-
ate and use a
PairOfDice
object.
PP 4.9 Design and implement a class called
Building
that represents
a graphical depiction of a building. Allow the parameters to
the constructor to specify the building's width and height. Each
building should be colored black and should contain a few ran-
dom windows of yellow. Create a program that draws a random
skyline of buildings.
PP 4.10 Write a program that displays a graphical seating chart for a
dinner party. Create a class called
Diner
(as in one who dines)
that stores the person's name, gender, and location at the dinner
table. A diner is graphically represented as a circle, color-coded
by gender, with the person's name printed in the circle.
PP 4.11 Create a class called
Crayon
that represents one crayon of a
particular color and length (height). Design and implement a
program that draws a box of crayons.
PP 4.12 Create a class called
Star
that represents a five-pointed star. Let
the constructor accept the width of the star and the coordinates
of the star's top point. Write a program that draws a sky con-
taining stars of various sizes.
PP 4.13 Modify the
Fahrenheit
program from this chapter so that it
displays a button that, when pressed, also causes the conversion
calculation to take place. That is, the user will now have the
option of either pressing Enter in the text field or pressing the
button. Have the listener that is already defined for the text field
also listen for the button push.
Search WWH ::
Custom Search