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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
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
2/3
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
Question 2 [30 points]:
Implement a client class to test the Apartment class as follows:
1. Create an array of Apartment objects of size 5.
2. Fill it with five Apartment objects according to your choice as a programmer (NOT from the user)
3. Print the description of all apartments in the array which are located in "Beirut"
4. Display the size assessment of each apartment in the array.
5. Display the city of all apartment objects that are formed of two stories
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 2/3 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 Question 2 [30 points]: Implement a client class to test the Apartment class as follows: 1. Create an array of Apartment objects of size 5. 2. Fill it with five Apartment objects according to your choice as a programmer (NOT from the user) 3. Print the description of all apartments in the array which are located in "Beirut" 4. Display the size assessment of each apartment in the array. 5. Display the city of all apartment objects that are formed of two stories
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY