Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following UML diagram for class Chair: table [ [ Chair ] , [ - weight: double ] , [ - distanceFromFrontWall: double

Given the following UML diagram for class Chair:
\table[[Chair],[-weight: double],[-distanceFromFrontWall: double],[-color: String],[-dateManufactured: Date],[+Chair()],[+Chair(weight: double,],[distanceFromFrontWall: double,],[color: String, dateManufactured:],[Date)],[+setWeight(weight: double): void],[+setDistanceFromFrontWall(],[distanceFromFrontWall: double): void],[+setColor(color: String): void],[+setDateManufactured(dateManufactured: Date): void],[+getWeight(): double],[+getDistanceFromFrontWall(): double],[+getColor(): String],[+getDateManufactured(): Date],[+moveChairForward(distance: double): void],[+moveChairBackward(distance: double): void]]
Please do the following:
1- Create a class file called Chair.java that implements the UML displayed above exactly as specified (same variable names, types, ...). Also, make sure that the no-arg constructor calls the all-argument constructor and provides default values for the properties.
2- Create a class file called Room.java that implements a class called Room that has the following properties and constructors/methods:
Properties (All Private): number (int), length (double), width (double), array of type Chair called chairs.
all-argument constructor that initializes all Room properties setter/getter methods for each of the properties above method 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).
You should also create a UML diagram for this class as described below.
3- Create a class file called Driver.java that implements the Driver class which should implement the following two methods:
main method which should create an array of room objects called rooms (For this program, set the size of the array to 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 those. 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.
displayRooms method 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 that). The table should be organized as follows:
number length width total chairs red yellow white
e.g.:
201
45.34
25.20
42
12
19
11
Your 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 (SEEDVALE) to generate all the random values described above (using the suitable methods in the Random class). NOT doing this step correctly will cause you to lose many points. IMPORTANT: What you need to turn in:
1- Using one of the free UML drawing tools ( e.g. UMLet ), draw a complete UML diagram for the Room class and insert an image of it in a Word file called room_uml.docx then put that file inside your project folder. In the UML, each student should replace the name of the properties length and width to length#### and width#### where #### is the last four digits of his/her university id number (this is only done in the UML and not in the implementation above).
yellow white
e.g.:
201
45.34
25.20
42
12
19
11
Your 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 (SEEDVALE) to generate all the random values described above (using the suitable methods in the Random class). NOT doing this step correctly will cause you to lose many points. IMPORTANT: What you need to turn in:
1- Using one of the free UML drawing tools ( e.g. UMLet ), draw a complete UML diagram for the Room class and insert an image of it in a Word file called room_uml.docx then put that file inside your project folder. In the UML, each student should replace the name of the properties length and width to length#### and width#### where #### is the last four digits of his/her university id number (this is only done in the UML and not in th
image text in transcribed

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

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions