Question: QUESTION 18 Classroom -class Number: int -capacity: int + Classroom 0 + Classroom (n: int, c: int) + setNumberin :int): void + setCapacity(c: int): void

QUESTION 18 Classroom -class Number: int -capacity: int + Classroom 0 + Classroom (n: int, c: int) + setNumberin :int): void + setCapacity(c: int): void + getNumber(): int + getCapacityo: int 1- Write a class declaration for Classroom class and add the two variables to the class declaration classNumber: is an int variable that holds the classroom number. capacity: is an int variable that holds the number of chairs the classroom can fit. 2- The class should have the following constructors: A constructor that accepts the following value as argument and assigns it to the appropriate fields: classroom number and capacity. A no-arg constructor that assigns 0 to the classroom number, and 0 to the capacity field. 3- Write mutator methods that store values in these fields and accessor methods that return the values in these fields as in above UML diagram. 4- Once you have written the class, write a separate program that creates two Classroom objects to hold the following data: classNumber capacity 101 20 102 22
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
