Java Reference
In-Depth Information
methods that calculate and return the volume and surface area
of the sphere (see PP 3.5 for the formulas). Include a toString
method that returns a one-line description of the sphere. Create a
driver class called MultiSphere , whose main method instantiates
and updates several Sphere objects.
PP 4.2
Design and implement a class called Dog that contains instance
data that represents the dog's name and age. Define the Dog con-
structor to accept and initialize instance data. Include getter and
setter methods for the name and age. Include a method to com-
pute and return the age of the dog in “person years” (seven times
the dogs age). Include a toString method that returns a one-line
description of the dog. Create a driver class called Kennel , whose
main method instantiates and updates several Dog objects.
VideoNote
Developing a solution
of PP 4.2.
PP 4.3
Design and implement a class called Car that contains instance
data that represents the make, model, and year of the car. Define
the Car constructor to initialize these values. Include getter and
setter methods for all instance data, and a toString method that
returns a one-line description of the car. Create a driver class
called CarTest , whose main method instantiates and updates sev-
eral Car objects.
PP 4.4
Design and implement a class called Box that contains instance
data that represents the height, width, and depth of the box. Also
include a boolean variable called full as instance data that rep-
resents whether the box is full or not. Define the Box construc-
tor to accept and initialize the height, width, and depth of the
box. Each newly created Box is empty (the constructor should
initialize full to false). Include getter and setter methods for all
instance data. Include a toString method that returns a one-
line description of the box. Create a driver class called BoxTest ,
whose main method instantiates and updates several Box objects.
PP 4.5
Design and implement a class called Book that contains instance
data for the title, author, publisher, and copyright date. Define
the Book constructor to accept and initialize this data. Include
setter and getter methods for all instance data. Include a
toString method that returns a nicely formatted, multi-line
description of the topic. Create a driver class called Bookshelf ,
whose main method instantiates and updates several Book
objects.
PP 4.6
Design and implement a class called Flight that represents an
airline flight. It should contain instance data that represents the
Search WWH ::




Custom Search