Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Create a class called Classroom. The UML follows: Classroom -building: String -roomNumber: int -numberSeats: int -numberOccupants: int -projector: boolean -workstation: boolean +Classroom(bldg: String, num:

Java Create a class called Classroom. The UML follows:

Classroom

-building: String

-roomNumber: int

-numberSeats: int

-numberOccupants: int

-projector: boolean

-workstation: boolean

+Classroom(bldg: String, num: int):

+Classroom(bldg: String, num: int, seats: int, occupied: int, proj: boolean, station: boolean):

+getRoomNumber(): int

+getNumberSeats(): int

+getNumberOccupants(): int

+getProjector(): boolean

+getWorkstation(): boolean

+getBuilding(): String

+setBuilding(bldg: String): void

+setRoomNumber(num: int): void

+setNumberSeats(seats: int): void

+increaseOccupants(): void

+decreaseOccupants(): void

+changeProjector(): void

+changeWorkstation(): void

+showStatus(): void

The constructors operate as follows:

The two-arg constructor sets the building to bldg. and roomNumber to num and, for the rest of the fields, sets each integer field to 0, and each boolean field to false

The six-arg constructor sets each field to the appropriate parameter passed. However, for numberSeats and numberOccupants, if the value passed is negative, set the value to 0 instead.

The accessor methods operate as follows:

The get methods simply return the current value of the requested field.

The showStatus method displays the values of all the fields in an easy-to-read manner for the user, labeling each value.

The mutator methods operate as follows:

The setRoomNumber method changes the roomNumber to the value passed.

The setBuilding method changes the building to the value passed.

The setNumberSeats method changes the number of seats in a classroom to the value passed.

If the method attempts to change the number of seats to something less than the number of occupants already in the room, it should display a message stating that it is not possible to remove any seats at this time, and it should not change the number of seats in the classroom.

It should also not allow a negative number of seats.

The increaseOccupants method should attempt to increase the number of occupants in a classroom by one.

If the classroom is already full (no seats left), it should state that it is not possible to add a new occupant because the classroom is full.

The decreaseOccupants method should attempt to decrease the number of occupants in a classroom by one.

If the classroom is empty, it should state that it is not possible remove an occupant because the classroom is empty.

The change methods simply change the appropriate field to its opposite. If the field is currently true, then it becomes false. If it is currently false, it becomes true.

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

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago