
USING C++
Using the class declaration below, implement the functions:
class Rectangle
{
private:
double width;
double length;
char *name;
void initName(char *);
public:
//constructors
Rectangle();
Rectangle(double, double,
char*);
//destructor
~Rectangle();
void setWidth(double);
void setLength(double);
void setWidth(char *);
void setLength(char *);
void setName(char *);
double getWidth() const;
double getLength() const;
void printName() const
{ cout << name; }
};
A few notes on the functions:
- initName(char *): this is a private member function. It should be the only function which dynamically allocates a char array to hold the name.
- setName(char *): this is a public member function which changes the name of the rectangle to a new name. It does not dynamically allocate memory, it only changes name.
Demonstrate your class works with a main() function that instantiates an array of three Rectangle objects, one for each room of a house, using the initializer list below. Then, use your setName() function to fix the name of “Offce” to “Office”. Finally, tell the user the name and area of each room, and the name of the room with the largest area.
Rectangle house[] = { Rectangle(10, 12, "Kitchen"),
Rectangle(20, 20, "Bedroom"),
Rectangle(8, 12, "Offce") };
You can either do this exercise all in one file or in multiple files (Multiple files preferred)

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 6 images

- In C++ programing,arrow_forwardConsider the following program written in C pseudocode: int a = 1; /* global */ void foo(int x){ a++;x = x + 2; } void main(){ foo(a); } For each of the following parameter-passing methods, what will be the values of a and b after running the program? 1) Passed by value 2) Passed by reference 3) Passed by value-resultarrow_forwardQuestion 12 Consider the following program written in C pseudocode: void foo(int x, int y){ y = y + 9; x = x + y; void main(){ int a = 6; int b = 5; foo(a, b); For each of the following parameter-passing methods, what will be the values of a and b after running the program? 1) Passed by value 2) Passed by reference 3) Passed by value-result 1.а - b = 2. a = b = 3. a = b =arrow_forward
- c) Draw a UML Diagram for the following source code. (CLO1, CLO2) public class MyCircle { double MyRadius= 0.0; MyCircle() { } MyÇircle(double newRadius) { MyRadius = newRadius; } double getArea() { return MyRadius * MyRadius * 3.14159;} public static void main(String[] args) { MyCircle C1 = new MyCircle(); C1 MyRadius = 2.0; MyCircle C2 = new MyCircle(); C2.MyRadius = 4.0; System.out.println(C1.getArea()); System.out println(C2,getArea(); } }arrow_forwardUSE C++ PLEASE Q#1 Using the concept of classes, constructors and data structure (arrays or any under data structure) implement a detailed University and student enrollment system. Each department of university has a separate class and perform every functionality with in a class. Create a main class where methods of other classes will be called.arrow_forwardC++ Define a problem with input, output, and Inheritance. If no output explain the reason why and what you are going to do make sure it does not happen again aka learning from your mistakes.Problem:Design:Code:Output:arrow_forward
- PROGRAMMING LANGUAGE: C++ I need the code for clockType.h , clockTypelmp.cpp , main.cpp CLOCKTYPE.H code provided in this exercise [EVALUATE THE GIVEN CODE AND PROVIDE THE CORRECT CODE] class clockType { public: void setTime(int, int, int); void getTime(int&, int&, int&) const; void printTime() const; void incrementSeconds(); void incrementMinutes(); void incrementHours(); bool equalTime(const clockType&) const; private: int hr; int min; int sec; };arrow_forwardInstructions-Java Assignment is to define a class named Address. The Address class will have three private instance variables: an int named street_number a String named street_name and a String named state. Write three constructors for the Address class: an empty constructor (no input parameters) that initializes the three instance variables with default values of your choice, a constructor that takes the street values as input but defaults the state to "Arizona", and a constructor that takes all three pieces of information as input Next create a driver class named Main.java. Put public static void main here and test out your class by creating three instances of Address, one using each of the constructors. You can choose the particular address values that are used. I recommend you make them up and do not use actual addresses. Run your code to make sure it works. Next add the following public methods to the Address class and test them from main as you go: Write getters and…arrow_forwardFor C++ Programming II D.S. Malik Programming Exercise 10-16: Write the definition of a class swimmingPool, to implement the properties of a swimming pool. Your class should have the instance variables to store the length (in feet), width (in feet), depth (in feet), the rate (in gallons per minute) at which the water is filling the pool, and the rate (in gallons per minute) at which the water is draining from the pool. Add appropriate constructors to initialize the instance variables. Also, add member functions to do the following: determine the amount of water needed to fill an empty or partially filled pool, determine the time needed to completely or partially fill or empty the pool, and add or drain water for a specific amount of time, if the water in the pool exceeds the total capacity of the pool, output "Pool overflow" to indicate that the water has breached capacity. The header file for the swimmingPool class has been provided for reference. Write a program to test your…arrow_forward
- 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





