Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design a class named Room that contains: 1. Five private data members name, location, capacity (persons), length, and width (in feet) of type String, String,

Design a class named Room that contains:

1. Five private data members name, location, capacity (persons), length, and width (in feet) of type String, String, int, double, and double respectively.

2. A default constructor that initializes the data members to none, none, 0, 0.0, 0.0 respectively.

3. A constructor with five arguments n, loc, c, l, and w to initialize the data members name, location, capacity, length, and width to n, loc, c, l, and w respectively.

4. Public getter and setter methods for each data member of the class Room.

5. A public method getArea() that returns the area of the room. Draw the UML diagram of the class and create the class in a file named Room.java

Write a test program (a different file named TestRoom.java in the same folder as Room.java) with a main method to do the following:

1. Create an array of type Room named cseRooms with size equal to 5 Room[] cseRooms = new Room[5];

2. Initialize the array with the following data: cseRooms[0] = new Room(sandbox lab,PL-112,65,15.5,30.75); cseRooms[1] = new Room(sunlab,PL-122,45,10,15); cseRooms[2] = new Room(classroom,PL-415,80,20,30); cseRooms[3] = new Room(faculty,PL-252,1,10.5,10.75); cseRooms[4] = new Room(admin office,PL-115,1,12.25,10.35);

3. Display, in tabular format using printf(), the attributes of the five rooms including the calculated area. Submit the files Room.java, TestRoom.java and the UML diagram of class Room on courseSite. Submit an image file for the UML diagram (drawing software output or scanned hand drawing).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Determine the energy required to move 240 C through 6 V

Answered: 1 week ago