Exercise 3: Consider a rectangle class that contains two attributes (length and width of real type). 1. Write a program that allows you to create this class that contains: o Both data private members. o The three constructors. o A destructor that displays a message indicating the destruction of the object. o An input function that allows you to input private member values according to the following two conditions. ▪ Length = width. Length > width. 2. Overload the == operator to compare two rectangles. Two rectangles are equal if at least one of their dimensions (length and width) is equal (They are equal in length or width, or the length of one is equal to the width of the other). 3. Overload the + operator to add two rectangles. o The result of the addition is a rectangle. o The resulting rectangle has two dimensions: the common dimension between the two rectangles and the dimension of the other is the sum of the two remaining dimensions (see figure below). o The longer between them is the length and the other is the width. o If the two rectangles do not have equal dimensions, The resulting rectangle will have (-1,-1) as dimensions.
Exercise 3: Consider a rectangle class that contains two attributes (length and width of real type). 1. Write a program that allows you to create this class that contains: o Both data private members. o The three constructors. o A destructor that displays a message indicating the destruction of the object. o An input function that allows you to input private member values according to the following two conditions. ▪ Length = width. Length > width. 2. Overload the == operator to compare two rectangles. Two rectangles are equal if at least one of their dimensions (length and width) is equal (They are equal in length or width, or the length of one is equal to the width of the other). 3. Overload the + operator to add two rectangles. o The result of the addition is a rectangle. o The resulting rectangle has two dimensions: the common dimension between the two rectangles and the dimension of the other is the sum of the two remaining dimensions (see figure below). o The longer between them is the length and the other is the width. o If the two rectangles do not have equal dimensions, The resulting rectangle will have (-1,-1) as dimensions.
Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter11: More Object-oriented Programming Concepts
Section: Chapter Questions
Problem 1GZ
Related questions
Question
C++
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 2 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.Recommended textbooks for you
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage