Create an Author Object. Assume a class called Author has already been defined, whose constructor accepts as arguments a string representing the author's full name and an integer representing the number of books the author has written. Declare a variable called "writer" of type Author and assign to it an Author object representing John Steinbeck, who wrote 33 books.
Solve It!
Treasure Chest Class. Write a complete class called TreasureChest that stores an int variable called "gold" as instance data. Include a constructor that gives an initial value to "gold" using the parameter value, as well as classic setter and getter methods for "gold". Also include a toString method that returns a description in the form "This chest contains 20 gold pieces" using the current gold value.
Solve It!
Box Class. Write a complete class called Box that represents a cardboard box with dimensions of length, width, and height. Include a constructor that has three int parameters named length, width, and height for the three dimensions, and a getVolume method that returns an int with the calculated volume of the box (length x width x height).
Solve It!