Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Define the class RectangularCube in C++. A RectangularCube has three sides length(L), width (W), and Height (h), define the sides as private data fields. Include a no-argument constructor that sets all three sides to 1. The class must also have a constructor that receive parameters to initialize sides of the RectangularCube. Include get and set functions for all three data fields. Finally define the functions volume () and surfaceArea () in the class RectangularCube that use the formulas given below to calculate and return the volume and the surface area of the RectangularCube.
- Give the UML diagram of the class, you may use the MSOffice/Visio to create the UML class diagram (best to download and use Visual paradigm tool, or any other free UML tool).
- Implement the class using separate files for definition and implementation, use inclusion guard to avoid duplicate code. Make sure to include at least one inline function implementation. Do not Implement the volume () and the SurfaceArea () as inline Include comments in your code.
- Write a test function for the class RectangularCube and perform the following tasks:
- Create two objects, one object using the no-argument constructor and another using the constructor with parameters (pick any values for the L, W, and H).
- Invoke the volume () and SurfaceArea () functions on both object and display their returned value.
- Invoke a set function on an object and change the value of one of the sides.
- Invoke the volume () and surfaceArea () functions on the object in part (c) and print their returned values.
- Assign (using the operator =) and anonymous RectanularCube object to the object in part (c). Once again invoke the volume () and surfaceArea () functions on the object in part (c).
- Code submission and sample output.
In this problem we will continue to expand on the initial problem
- Write the function with the header void printCube (RectangularCube rc) that receives an object of the type RectangularCube and displays the length, width, height, volume and the surface area of the cube like: L = 2, W = 1, H = 1, V = 2, A = 8. This function should be implemented as a non-member function, meaning that it should be defined outside the class RectangularCube.
- Write a main function in which you declare an array of 5 RectangularCube objects. Inside the main function, use a loop to initialize/populate this array of RectangularCube. In the body of the loop use the rand () function to generate random integers between 1 and 10 to assign to length, width and height data fields of each RectangularCube object
- After populating the array, use another loop to display individual elements of the array in part (a) by calling the function printCube in part (a)
- Code submission and sample output
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 5 images
Knowledge Booster
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
- Kindly Solve this C++ question as per the instructions. Thank you for your help! Instructions: 1- Put the class definition in Flight.h and the implementation of the constructors and functions in Flight.cpp Implement the Flight.h and Flight.cpp so that class Flight contains: 4 private instance variables: Name of data type string, which describe the three electric vehicle charger types (AC975, DL521, and AC863). Destination of data type string that shows the final destination of that flight. Hour and Minute of data type int that show the departure time. A default constructor which sets all of the numeric instance variables to zero and the String instance variables to null. A constructor with 4 parameters that sets the 4 instance variables to the corresponding values passed. Implement an accessor method for each information (Flight name, Flight destination, and Flight Time) that will return the value of the instance variable. For example, the getX() method for the instance variables…arrow_forwardTo avoid making private types public, explain why accessors are better in each of the following three cases.arrow_forwardIn C++ Please: THE PROGRAM CANNOT CONTAIN -> OPERATORS! Create a class AccessPoint with the following: x - a double representing the x coordinate y - a double representing the y coordinate range - an integer representing the coverage radius status - On or Off Add constructors. The default constructor should create an access point object at position (0.0, 0.0), coverage radius 0, and Off. Add accessor and mutator functions: getX, getY, getRange, getStatus, setX, setY, setRange and setStatus. Add a set function that sets the location coordinates and the range. Add the following member functions: move and coverageArea. Add a function overLap that checks if two access points overlap their coverage and returns true if they do. Add a function signalStrength that returns the wireless signal strength as a percentage. The signal strength decreases as one moves away from the access point location. Represent this with bars like, IIIII. Each bar can represent 20% Test your class by writing a…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education