Test #1 Create a class called Rectangle. Use the UML below to define the methods in the class. Create a folder on the linux server called test1 and write and test your code in that area. An executable program must be on the linux server. Hit submit on the assignment page when you have completed the test.   Use a similar driver as below to test your class. #include #include"Rectangle.h" int main(){ Rectangle r1(1.2, 3.4); cout<

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Test #1

Create a class called Rectangle. Use the UML below to define the methods in the class. Create a folder on the linux server called test1 and write and test your code in that area. An executable program must be on the linux server. Hit submit on the assignment page when you have completed the test.

 

Use a similar driver as below to test your class.

#include<iostream>

#include"Rectangle.h"

int main(){

Rectangle r1(1.2, 3.4);

cout<<r1.toString()<<endl;

Rectangle r2;

cout<<r2.toString()<<endl;

 

// Test setters and getters

r1.setLength(5.6);

r1.setWidth(7.8);

cout<<r1.toString()<<endl;

cout<<"length is: " <<r1.getLength()<<endl;

cout<<"width is: "<<r1.getWidth()<<endl;

 

// Test getArea() and getPerimeter()

cout<<"area is: "<<r1.getArea()<<endl;

cout<<"perimeter is: "<<r1.getPerimeter()<<endl;

}

 

Output Should be something like the following:

Rectangle[length=1.2,width=3.4]

Rectangle[length=1.0,width=1.0]

Rectangle[length=5.6,width=7.8]

length is: 5.6

width is: 7.8

area is: 43.68

perimeter is: 26.80

 

Rectangle
-length: float 1.0f
=
-width: float = 1.0f
+Rectangle()
+Rectangle (length: float, width: float)
+getLength(): float
+setLength (length: float):void
+getWidth(): float
+setWidth (width: float):void
+getArea(): double
+getPerimeter(): double
+toString(): String
"Rectangle[length=?,width=?]"
Transcribed Image Text:Rectangle -length: float 1.0f = -width: float = 1.0f +Rectangle() +Rectangle (length: float, width: float) +getLength(): float +setLength (length: float):void +getWidth(): float +setWidth (width: float):void +getArea(): double +getPerimeter(): double +toString(): String "Rectangle[length=?,width=?]"
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Class
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education