Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Room class should have the following properties: number ( int ) , length ( double ) , width ( double ) , and an

The Room class should have the following properties: number (int), length (double), width (double), and an array of type Chair called chairs. All these properties should be private.The Room class should also have an all-argument constructor that initializes all its properties. It should also have setter/getter methods for each of the properties.The Room class should also have a method called displayRoomInfo() which prints a room's number, length, width, and total number of chairs in a room, as well as the number of chairs of each color (red, yellow, or white).The Driver class should have a main method which creates an array of room objects called rooms. The size of the array should be exactly 3.To initialize the property values for each room in array rooms, you should do the following:a- Create an array of chairs with a random number of chairs between 20 and 50(inclusive) and add that number of Chair objects to the array. Each Chair object added to the array should be given the same default value for properties weight and dateManufactured. As for property distanceFromFrontWall, each chair should be given a random value that does not exceed the length of the room. For the property color, you should assign a random color out of the following three colors only (red, yellow, or white). Use the Random class to do this.b- Use the all-argument Room constructor to set a number for each room (Use 201,202,203 sequentially in this case), a random number from 30.0 to 50.0 for room length, and a random number from 20.0 to 30.0 for room width. Use the Random class. Also set the room chairs using the array created in point a- above.The Driver class should also have a method called displayRooms which takes an array of type Room as an argument and loops through it displaying the property values for each room in the array. You should call the method displayRoomInfo() to do this.The Driver class should define a constant called SEEDVALUE which is the value of the seed to be used when you create your object of Random Type to be used in all your program. You should use the same created Random object (ONE OBJECT ONLY) with the same seed (SEEDVALUE) to generate all the random values described above.Here is a sample code snippet for the Room class:

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_2

Step: 3

blur-text-image_3

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

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions