Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

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=?]"
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education