Room.java: public class Room { // fields private String roomNumber; private String buildingName; private int capacity; public Room() { this.capacity = 0; } /** * Constructor for...

50.1K

Verified Solution

Question

Programming

Room.java:

public class Room
{
// fields
private String roomNumber;
private String buildingName;
private int capacity;

public Room()
{
this.capacity = 0;
}
/**
* Constructor for objects of class Room
*
* @param rN the room number
* @param bN the building name
* @param c the room capacity
*/
public Room(String rN, String bN, int c)
{
setRoomNumber(rN);
setBuildingName(bN);
setCapacity(c);
}
  
/**
* Mutator method (setter) for room number.
*
* @param rN a new room number
*/
public void setRoomNumber(String rN)
{
this.roomNumber = rN;
}
  
/**
* Mutator method (setter) for building name.
*
* @param bN a new building name
*/
public void setBuildingName(String bN)
{
this.buildingName = bN;
}
  
/**
* Mutator method (setter) for capacity.
*
* @param c a new capacity
*/
public void setCapacity(int c)
{
this.capacity = c;
}
  
/**
* Accessor method (getter) for room number.
*
* @return the room number
*/
public String getRoomNumber()
{
return this.roomNumber;
}
  
/**
* Accessor method (getter) for building name.
*
* @return the building name
*/
public String getBuildingName()
{
return this.buildingName;
}
  
/**
* Accessor method (getter) for capacity.
*
* @return the capacity
*/
public int getCapacity()
{
return this.capacity;
}
}

Put the ideas into practice by extending the original Room classto create an AcademicRoom.java class.

  1. The AcademicRoom.java should store information aboutthe building name, room number, capacity, academic departmentassociated with the room (CPSC, MATH, BUAD, ...) and also whetheror not the room contains a projector. Make sure to utilizeinheritance (only add new fields to AcademicRoom).
  2. Include a constructor for the AcademicRoom class thattakes advantage of the reserved word super. Also includeappropriate getter/setter methods for theAcademicRoom.
  3. Add James Farmer B6 to your list as well as two orthree other classrooms of your choosing.
  4. Implement a test program (TestAcademicRoom.java) with amain() that creates an ArrayList of AcademicRooms. After the listis created, allow the user to: (1) add another room to the list,and (2) search for rooms. The program should not add the room if italready exists in the list. The user should search by inputting abuilding name and optionally a room number. If a room number is notprovided, the program should print all rooms in that building. Ifmatches are found in the list, print all the data membersassociated with the AcademicRoom(s).

Answer & Explanation Solved by verified expert
3.6 Ratings (373 Votes)
import javautilArrayList public class AcademicRoom extends Room String AcademicDepartment Boolean projector public AcademicRoomString buildingName String roomNo int capacity String department Boolean projector superroomNo buildingName capacity setAcademicDepartmentdepartment setProjectorprojector public void setAcademicDepartmentString academicDepartment thisAcademicDepartment academicDepartment public void setProjectorBoolean projector thisprojector projector public String getAcademicDepartment return thisAcademicDepartment public Boolean getProjector return thisprojector Override public String toString return Room No getRoomNumber Building Name getBuildingName Capacity    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students