Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class called Cuboid in a file called cuboid.py. The constructor should take parameters that sets a private variable for each side of the

Create a class called Cuboid in a file called cuboid.py. The constructor should take parameters that sets a private variable for each side of the cuboid. Overload the following operators: +, -, <, >, ==, len(), and str(). Return a cuboid with the appropriate volume for the arithmetic operators. Use the volume of the cuboid to determine the output of the overloaded comparison operators. Use the surface area of the cuboid to calculate the result of len(). For str() return a string that displays the side lengths, volume, and surface area. Let the user enter values used to create two Cuboid objects. Then print out all results of the overloaded operators (using the operator, not calling the dunder method). Create a file called assn14-task1.py that contains a main() function to run your program. It is fine for the program to only run once then end. You DO NOT need to create loop asking use if they want to "Play Again". Note: The most complicated part of this is the + and -. Remember that arithmetic operators should return the same type as the operands, so a cuboid should be returned. The returned cuboid is based on the volume, which means you'll need to figure out what the side lengths should be. They can be anything valid.

I was previously referring to the other solution on here, but it does not return a new cuboid, it just returns the values between cuboid 1 and cuboid 2. They want us to use the overload operators to return a new cuboid that has any valid length/width/height that would be the result of the two initial cuboids added or subtracted together.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions