Write a class definition for the class called Bookshelf described below: • Private member variables: • shelves: an integer representing the number of shelves on the bookcase. shelfHeight: a double representing the height of each individual shelf in inches. All shelves share the same height. • Member methods: • A constructor which has 2 arguments, one each to set the initial values of the two member variables. Neither of these arguments is allowed to be 0 or less: . If the number of shelves is entered as O or less, set it to 6 inside of the constructor instead. . If the height of each shelf is entered as O or less, set it to 12 inside of the constructor instead. o getBookshelf Height: a method which returns the total height of the bookshelf in feet (as a double). The height of the bookshelf can be obtained by multiplying the height of each shelf by the number of shelves, then dividing by 12 (to convert from inches to feet)

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter11: More Object-oriented Programming Concepts
Section: Chapter Questions
Problem 2RQ
icon
Related questions
Question

Java

Write a class definition for the class called Bookshelf described below:
• Private member variables:
• shelves: an integer representing the number of shelves on the bookcase.
• shelfHeight: a double representing the height of each individual shelf in
inches. All shelves share the same height.
• Member methods:
• A constructor which has 2 arguments, one each to set the initial values of the
two member variables. Neither of these arguments is allowed to be 0 or less:
▪ If the number of shelves is entered as O or less, set it to 6 inside of the
constructor instead.
O
■ If the height of each shelf is entered as O or less, set it to 12 inside of the
constructor instead.
getBookshelfHeight: a method which returns the total height of the
bookshelf in feet (as a double). The height of the bookshelf can be obtained
by multiplying the height of each shelf by the number of shelves, then
dividing by 12 (to convert from inches to feet)
Transcribed Image Text:Write a class definition for the class called Bookshelf described below: • Private member variables: • shelves: an integer representing the number of shelves on the bookcase. • shelfHeight: a double representing the height of each individual shelf in inches. All shelves share the same height. • Member methods: • A constructor which has 2 arguments, one each to set the initial values of the two member variables. Neither of these arguments is allowed to be 0 or less: ▪ If the number of shelves is entered as O or less, set it to 6 inside of the constructor instead. O ■ If the height of each shelf is entered as O or less, set it to 12 inside of the constructor instead. getBookshelfHeight: a method which returns the total height of the bookshelf in feet (as a double). The height of the bookshelf can be obtained by multiplying the height of each shelf by the number of shelves, then dividing by 12 (to convert from inches to feet)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage