Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For your assignment you are to develop a java class named MatchBox. Your class MatchBox must extend the class Box and in addition to the
For your assignment you are to develop a java class named MatchBox. Your class MatchBox must extend the class Box and in addition to the attributes width, height, and depth that are defined in the class Box, MatchBox must add a new attribute weight. The eetvolume method must both report the values of width, height, depth, and weight, but must also calculate and report the volume by multiplying height by width by depth. The class MatchBox must also add the method calculatebweight) that will calculate weight based upon the volume assuming that the volume is a quantity of water which weighs.03611 pounds per cubic inch. Also method calculatelieight should show the result like this: weight of MatchBox is X. For example a car class can inherit some properties from a General vehicle class. Here we find that the base class is the vehicls and the subclass is the more specific car class. A subclass must use the extends clause to derive from a super class which must be written in the header of the subclass definition. The subclass inherits members of the superclass and hence promotes code reuse. The subclass itself can add its own new behavior and properties. Your new class must include a main method that creates a new MatchBox object, calls the getvolume method and reports the results by printing the following items to the screen (where the X is replaced by the calculated value) For your assignment, assume that the value of width is 5, height is 10, and the depth is 3. The output should look like the following with X replaced with the appropriate calculated value width of MatchBox is X height of MatchBox is X depth of MatchBox is X weight of MatchBox is X Volume is: X
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started