Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define a squared three-dimensional cube class, emphasizing individual access to data fields. It should have (three properties): the length of the side (length, width, &

Define a squared three-dimensional cube class, emphasizing individual access to data fields. It should have (three properties):

the length of the side (length, width, & depth are all the same length value so only one field is needed), the color of the cube (as a String, not a Color object), and a boolean fill value whether the cube should be filled (or hollow).

It should be able to (ten methods):

create a default fully functional unfilled black cube of length one

set the values for all fields (individually)

get the values for all fields (individually)

calculate and return the surface area and volume of the cube (individually)

resize the length of the cube by a percentage (ex. .25 would increase the length by 25%, -.10 would decrease the length by 10%)

Use proper rules for access and OOP in the Cube definition. Use Math methods where possible in calculations.

Create the main class. It should:

Create an array of three cube references

In a loop:

instantiate the next cube object and assign to the next spot in the array Ask the user if they would like to change their cube. If they say yes: prompt & input from the user the length, color, and fill put the values into the objects data field (individually) Ask the user if they would like to resize their cube If they say yes: prompt and input the percentage to resize the length of the cube call the resize method with that percentage to resize the length of the cube Whatever the user answered to the questions: In another loop: (Print the number fields to 2 decimal places). print all labeled data fields separately returned from the classes methods. call the methods to calculate and return to print the surface area and volume. Add sufficient documentation to both class files - name, exercise, at least 4 lines about purpose at the top of both files, and at least 5 comments throughout each file explaining what is going on (ex. what methods do or explain a line of code's purpose, etc.)

Run the program one time, with the data below. Save (or Copy and Paste) the Console running of your program into a plain output .txt text file. Submit your cube.java class definition, the source code main program, and the output .txt saved (clear Console, run, save Console).

Data for one run:

Cube 0: say no to change; say yes to resize; resize: .25;

Cube 1: say yes to change; length: 2.0; color: Cyan; fill: true; say yes to resize; resize: -.10;

Cube 2: say yes to change; length: 5.7; color: Blue; fill: false; say no to resize;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

LO2 Identify components of workflow analysis.

Answered: 1 week ago