Data Fields: 1. city: It may consist of one word or two such as "Beiruť", “Bint Jbeil", etc. 2. area: its value is expressed in square meter 3. nbOfRooms: with maximum value of 10 4. duplex: either true or false to reflect whether the apartment is made of two stories or only a single one. 5. num_apt: to keep track of how many apartment objects were created. Methods: 1. A constructor that creates an Apartment object with the specified values of all data fields. If the number of rooms passed is greater than 10, then nbOfRooms is set to 0. 2. getCity(): this method returns the city with its letters all capitalized. 3. getNumberOfStories(): This method returns the number of stories of an apartment. If it is duplex, then 2 is returned otherwise 1 is returned. 4. assessSize(): This method returns "Spacious" if the area is greater than 150 square meter, "Small" if it is less than 100 and “Medium" otherwise. 5. printDescription(): Method that displays the information of the apartment as in the following examples: Example 1> Spacious 2 stories Apt in HAMRA - 250.0 (sqm) - 6 room(s) Example 2- Small 1 story Apt in ZAHLE- 50.0 (sam) - 1 room

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
Implement the class as depicted in the UML diagram.
Apartment
-city: String
-area: double
-nbOfRooms: int
-duplex: boolean
+num_apt: int
+Apartment(----All data fields----)
+getCity(): String
+getNumberOfStories(): int
+assessSize(): String
+printDescription(): void
Data Fields:
1. city: It may consist of one word or two such as “Beirut", “Bint Jbeil", etc.
2. area: its value is expressed in square meter
3. nbOfRooms: with maximum value of 10
4. duplex: either true or false to reflect whether the apartment is made of two stories or only a single one.
5. num_apt: to keep track of how many apartment objects were created.
Methods:
1. A constructor that creates an Apartment object with the specified values of all data fields. If the number
of rooms passed is greater than 10, then nbOfRooms is set to 0.
2. getCity(): this method returns the city with its letters all capitalized.
3. getNumberOfStories(): This method returns the number of stories of an apartment. If it is duplex, then 2
is returned otherwise 1 is returned.
4. assessSize(): This method returns "Spacious" if the area is greater than 150 square meter, “Small" if it is
less than 100 and “Medium" otherwise.
5. printDescription(): Method that displays the information of the apartment as in the following examples:
Example 1→ Spacious 2 stories Apt in HAMRA - 250.0 (sqm) - 6 room(s)
Example 2→ Small 1 story Apt in ZAHLE- 50.0 (sqm) - 1 room
Transcribed Image Text:Implement the class as depicted in the UML diagram. Apartment -city: String -area: double -nbOfRooms: int -duplex: boolean +num_apt: int +Apartment(----All data fields----) +getCity(): String +getNumberOfStories(): int +assessSize(): String +printDescription(): void Data Fields: 1. city: It may consist of one word or two such as “Beirut", “Bint Jbeil", etc. 2. area: its value is expressed in square meter 3. nbOfRooms: with maximum value of 10 4. duplex: either true or false to reflect whether the apartment is made of two stories or only a single one. 5. num_apt: to keep track of how many apartment objects were created. Methods: 1. A constructor that creates an Apartment object with the specified values of all data fields. If the number of rooms passed is greater than 10, then nbOfRooms is set to 0. 2. getCity(): this method returns the city with its letters all capitalized. 3. getNumberOfStories(): This method returns the number of stories of an apartment. If it is duplex, then 2 is returned otherwise 1 is returned. 4. assessSize(): This method returns "Spacious" if the area is greater than 150 square meter, “Small" if it is less than 100 and “Medium" otherwise. 5. printDescription(): Method that displays the information of the apartment as in the following examples: Example 1→ Spacious 2 stories Apt in HAMRA - 250.0 (sqm) - 6 room(s) Example 2→ Small 1 story Apt in ZAHLE- 50.0 (sqm) - 1 room
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Returning value from Function
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
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