Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hey guys, could use some help with this Java Inheritance assignment. I’ve attach

ID: 3733118 • Letter: H

Question

Hey guys, could use some help with this Java Inheritance assignment. I’ve attached my current code and full instructions in the drive link below, but here is the second requirement for an idea what’s going on, as i've said the full requirements are in the link.

Requirement#2

Create a class called RoomUtil. Create a static method in this class which will provide the output in Figure 1. This method should accept the rooms ArrayList from the main method when option 5 is chosen. It should not access anything from outside the class and should only accept the ArrayList as a parameter! The largest room can be any type of room, but the user of the report wants to see the largest room in terms of number of seats. The exit option should always be the last option - so if you add an option the exit may have to be changed.

Drive Link - https://drive.google.com/drive/folders/1i1HaW0yCt3rR0Zu7UfHUESm8nwlKIlhG?usp=sharing

Explanation / Answer

package info.hccis.room.bo;


import java.util.Scanner;

/**
* Computer room is a room which is equipped with computer stations.
*
* @since 20170314
* @author CIS1232
*/
public class ComputerRoom extends Room {

int numberOfComputers;

/**
* Default constructor
*/
public ComputerRoom() {
}

/**
* Custom constructor that sets all of the class attributes.
*
* @param numberOfComputers
* @param roomNumber
* @param numberOfSeats
* @param reserved
* @param hasSmartBoard
* @since 20180313
* @author BJM
*/
public ComputerRoom(int numberOfComputers, int roomNumber, int numberOfSeats, boolean reserved, boolean hasSmartBoard) {
super(roomNumber, numberOfSeats, reserved, hasSmartBoard);
this.numberOfComputers = numberOfComputers;
}
  
  
/**
* Get the details from the user about this class. This will invoke the
* super method to get the base class attributes.
*
* @since 20170314
* @author CIS1232
*/
public void getRoomDetailsFromUser() {
super.getRoomDetailsFromUser();
Scanner input = new Scanner(System.in);
System.out.print("Enter number of computers: ");
numberOfComputers = input.nextInt();
input.nextLine();
}

public int getNumberOfComputer() {
return numberOfComputers;
}

public void setNumberOfComputer(int numberOfComputer) {
this.numberOfComputers = numberOfComputer;
}

public String toString() {
return super.toString() + " Number of Computers" + numberOfComputers;
}
}

---------------------------------------------------------------------------------------------------------------------------------------------------------

package info.hccis.room.bo;

import java.util.Scanner;

/**
* BoardRoom is a type of room used for meetings
*
* @since 20170314
* @author CIS1232
*/
public class BoardRoom extends Room {

private boolean hasTeleconferencing;

/**
* default constructor
*
* @since 20180313
* @author BJM
*/
public BoardRoom() {
}

/**
* Custom constructor which sets all attributes of the class
*
* @param hasTeleconferencing
* @param roomNumber
* @param numberOfSeats
* @param reserved
* @param hasSmartBoard
* @author BJM
* @since 20180313
*/
public BoardRoom(boolean hasTeleconferencing, int roomNumber, int numberOfSeats, boolean reserved, boolean hasSmartBoard) {
super(roomNumber, numberOfSeats, reserved, hasSmartBoard);
this.hasTeleconferencing = hasTeleconferencing;
}

public boolean isHasTeleconferencing() {
return hasTeleconferencing;
}

public void setHasTeleconferencing(boolean hasTeleconferencing) {
this.hasTeleconferencing = hasTeleconferencing;
}

public String toString() {
return super.toString() + " Has teleconferencing: " + hasTeleconferencing;
}

/**
* Get the details from the user about this class. This will invoke the
* super method to get the base class attributes.
*
* @since 20170314
* @author CIS1232
*/
public void getRoomDetailsFromUser() {
super.getRoomDetailsFromUser();
Scanner input = new Scanner(System.in);
System.out.print("Does this room have teleconferencing (y/n) ");
hasTeleconferencing = input.nextLine().equalsIgnoreCase("y");
;
}
}

---------------------------------------------------------------------------------------------------------------------------------------------------------

package info.hccis.room.bo;

import java.util.Scanner;

/**

*

* This is the base type of room. Has the basics for a class room but not much

* specialized equipment.

*

* @since 20170314

* @author CIS1232

*/

public class Room {

Scanner input = new Scanner(System.in);

private int roomNumber;

private int numberOfSeats;

private String reservedBy = "";

private boolean reserved;

private boolean hasSmartBoard;

/**

* Default constructor

*

* @since 20180313

* @author BJM

*/

public Room() {

}

/**

* Custom constructor that accepts all of the attributes of the class.

*

* @param roomNumber

* @param numberOfSeats

* @param reserved

* @param hasSmartBoard

* @since 20180313

* @author BJM

*/

public Room(int roomNumber, int numberOfSeats, boolean reserved, boolean hasSmartBoard) {

this.roomNumber = roomNumber;

this.numberOfSeats = numberOfSeats;

this.reserved = reserved;

this.hasSmartBoard = hasSmartBoard;

}

public Room(int roomNumber, int numberOfSeats, String reservedBy, boolean reserved, boolean hasSmartBoard) {

this.roomNumber = roomNumber;

this.numberOfSeats = numberOfSeats;

this.reservedBy = reservedBy;

this.reserved = reserved;

this.hasSmartBoard = hasSmartBoard;

}

/**

* Get the attribute values from the user.

*

* @since 20170314

* @author CIS1232

*/

public void getRoomDetailsFromUser() {

System.out.print("Enter number of seats: ");

numberOfSeats = input.nextInt();

input.nextLine();

System.out.print("Does this classroom have a smart board? (y/n)");

hasSmartBoard = input.nextLine().equalsIgnoreCase("y");

}

public boolean isHasSmartBoard() {

return hasSmartBoard;

}

public void setHasSmartBoard(boolean hasSmartBoard) {

this.hasSmartBoard = hasSmartBoard;

}

public int getNumberOfSeats() {

return numberOfSeats;

}

public void setNumberOfSeats(int numberOfSeats) {

this.numberOfSeats = numberOfSeats;

}

public String getReservedBy() {

return reservedBy;

}

public void setReservedBy(String reservedBy) {

this.reservedBy = reservedBy;

}

public boolean isReserved() {

return reserved;

}

public void setReserved(boolean reserved) {

this.reserved = reserved;

}

public void setRoomNumber(int roomNumber) {

this.roomNumber = roomNumber;

}

public int getRoomNumber() {

return roomNumber;

}

/**

* Update the room to reserved and get the reserved by.

*

* @since 20170314

* @author CIS1232

*/

public void reserveThisRoom() {

this.reserved = true;

System.out.println("Enter the name of the person reserving this room: ");

reservedBy = input.nextLine();

}

/**

* Update the room to not reserved and clear the reserved by.

*

* @since 20170314

* @author CIS1232

*/

public void releaseThisRoom() {

this.reserved = false;

reservedBy = "";

System.out.println("Room has been released ");

}

public String toString() {

String output = " " + " Room Number: " + roomNumber + " Number of Seats: " + numberOfSeats

+ " Reserved By: " + reservedBy + " Reserved: " + reserved + " Smart Board: " + hasSmartBoard;

return output;

}

}

---------------------------------------------------------------------------------------------------------------------------------------------------------

package info.hccis.room.main;

import info.hccis.room.bo.ComputerRoom;

import info.hccis.room.bo.BiologyLab;

import info.hccis.room.bo.BoardRoom;

import info.hccis.room.bo.Room;

import info.hccis.room.util.RoomUtil;

import java.util.ArrayList;

import java.util.Scanner;

/**

* This main method will invoke functionality for booking college rooms.

*

* Detailed description: https://docs.google.com/document/d/

* 1jyrvSJHXS6BZuXKVswYkmt2muBmPI71OxXTLQxerDVU/edit

*

* @author cis1232 (including Roger)

*/

public class RoomMain {

private static final int ROOM_DOES_NOT_EXIST = -1;

private static ArrayList<Room> rooms = new ArrayList<Room>();

/**

* Main method controls program and user interface.

*

* @param args

* the command line arguments

* @since 20170314

* @author CIS1232

*/

public static void main(String[] args) {

/* Accessing values from main method */

// int roomNumber = Integer.parseInt(args[0]);

// int numberOfSeats = Integer.parseInt(args[1]);

// String reservedBy = args[2];

// boolean reserved = Boolean.parseBoolean(args[3]);

// boolean hasSmartBoard =Boolean.parseBoolean(args[4]);

//

// Room room = new

// Room(roomNumber,numberOfSeats,reservedBy,reserved,hasSmartBoard);

int roomNumber = 115;

int numberOfSeats = 50;

String reservedBy = "smith";

boolean reserved = false;

boolean hasSmartBoard = false;

Room room = new Room(roomNumber, numberOfSeats, reservedBy, reserved, hasSmartBoard);

ArrayList<Room> listOfRooms = new ArrayList<Room>();

listOfRooms.add(room);

RoomUtil.createTestRooms(rooms);

Scanner input = new Scanner(System.in);

String menu = "------------------------ - CIS Room Booking " + "------------------------ "

+ "Choose an option: " + "1) Add Room " + "2) Reserve Room " + "3) Release Room "

+ "4) Show Rooms " + "5) Show Room Count Details " + "6) Search For Room " + "7) Exit";

int selection = 0;

while (selection != 7) {

System.out.println(menu);

selection = input.nextInt();

input.nextLine();

switch (selection) {

case 1:

addRoom();

break;

case 2:

reserveRoom();

break;

case 3:

releaseRoom();

break;

case 4:

showRooms();

break;

case 5:

RoomUtil.createTestRooms(listOfRooms);

Room largestRoomOnNumberOfSeats = largestRoomOnNumberOfSeats(room);

break;

case 6:

break;

case 7:

System.out.println("Goodbye");

break;

default:

System.out.println("Invalid option.");

}

}

}

public static Room largestRoomOnNumberOfSeats(Room room) {

Room roomForBoardRoom = room;

roomForBoardRoom.setNumberOfSeats(50);

Room roomComputerRoom = room;

roomComputerRoom.setNumberOfSeats(40);

if (roomForBoardRoom.getNumberOfSeats() > roomComputerRoom.getNumberOfSeats()) {

System.out.println("ComputerRoom is largest room in terms of Number fo seats");

ComputerRoom computerRoom = new ComputerRoom(20, 251, roomComputerRoom.getNumberOfSeats(), false, false);

return computerRoom;

} else {

System.out.println("BoardRoom is largest room in terms of Number fo seats");

BoardRoom boardRoom = new BoardRoom(false, 115, roomForBoardRoom.getNumberOfSeats(), false, false);

return boardRoom;

}

}

/**

* Loop through the rooms to check if the room already exists.

*

* @param roomNumber

* @return the index of the room number

* @since 20170314

* @author CIS1232

*/

public static int getRoomNumberIfExists(int roomNumber) {

int index = -1;

for (int i = 0; i < rooms.size(); i++) {

if (rooms.get(i).getRoomNumber() == roomNumber) {

index = i;

}

}

return index;

}

/**

* This method will allow the user to add a new room to the collection of

* rooms.

*

*/

public static void addRoom() {

// ***********************************************************

// Ask which room number the user wants to add

// ***********************************************************

Room room = null;

Scanner input = new Scanner(System.in);

System.out.print("Enter room number: ");

int roomNumber = input.nextInt();

input.nextLine();

// ***********************************************************

// Check to see if the room already exists

// ***********************************************************

int roomNumberIndex = getRoomNumberIfExists(roomNumber);

// If the room does not already exist.

if (roomNumberIndex == ROOM_DOES_NOT_EXIST) {

roomNumberIndex = rooms.size();

boolean finished = false;

do {

System.out.print("What type of room is this? " + "1) Add Room " + "2) Computer Lab "

+ "3) Board Room " + "4) Biology lab ");

String choice = input.nextLine();

// ***********************************************************

// Based on the user input, create the correct type of room.

// ***********************************************************

switch (choice) {

case "1":

room = new Room();

finished = true;

break;

case "2":

room = new ComputerRoom();

finished = true;

break;

case "3":

room = new BoardRoom();

finished = true;

break;

case "4":

room = new BiologyLab();

finished = true;

break;

default:

System.out.println("Invalid option");

}

} while (!finished);

// Set the details for the room

room.setRoomNumber(roomNumber);

// Note the correct method will be invoked based on which type of

// room was created above.

room.getRoomDetailsFromUser();

// Add the room to the collection of rooms. Note that as long as an

// object 'is a' Room

// (all of the types of rooms above are rooms), then it can be added

// to the collection of

// rooms.

rooms.add(room);

} else {

String choice = "";

System.out.println("Room already exists. Do you want to continue? (Y/N)");

choice = input.nextLine();

// If the user wants to continue, invoke the method to change the

// value of attributes in

// the room

if (choice.equalsIgnoreCase("y")) {

rooms.get(roomNumberIndex).getRoomDetailsFromUser();

}

}

}

/**

* This method will allow the user to reserve a room.

*/

public static void reserveRoom() {

Scanner input = new Scanner(System.in);

System.out.println("Enter the room number you would like to book");

int roomNumber = input.nextInt();

input.nextLine();

// Check to see if the room exists.

int roomNumberIndex = getRoomNumberIfExists(roomNumber);

if (roomNumberIndex < 0) {

System.out.println("This room does not exist");

} else {

// Put the room from the ArrayList into a local variable.

Room room = rooms.get(roomNumberIndex);

if (!room.isReserved()) {

room.reserveThisRoom();

} else {

System.out.println("This room is already booked!");

}

}

}

public static void releaseRoom() {

Scanner input = new Scanner(System.in);

System.out.println("Enter the room number you would like to release");

int roomNumber = input.nextInt();

input.nextLine();

// Check if the room exists.

int roomNumberIndex = getRoomNumberIfExists(roomNumber);

if (roomNumberIndex < 0) {

System.out.println("This room does not exist");

} else {

// Put the room from the ArrayList into a local variable.

Room room = rooms.get(roomNumberIndex);

// If the room is reserved, allow them to release.

if (room.isReserved()) {

room.releaseThisRoom();

} else {

System.out.println("This room is not booked!");

}

}

}

/**

* Show the details for each room

*/

public static void showRooms() {

System.out.println("");

System.out.println("------------------------");

System.out.println("- Room List");

System.out.println("------------------------");

if (rooms.size() == 0) {

System.out.println("There are no rooms.");

}

for (int i = 0; i < rooms.size(); i++) {

System.out.println(rooms.get(i));

}

System.out.println("");

}

}

---------------------------------------------------------------------------------------------------------------------------------------------------------

package info.hccis.room.util;

import info.hccis.room.bo.BoardRoom;

import info.hccis.room.bo.ComputerRoom;

import info.hccis.room.bo.Room;

import java.util.ArrayList;

/**

*

* @author bjmaclean

*/

public class RoomUtil {

public static void createTestRooms(ArrayList<Room> rooms) {

System.out.println(rooms);

rooms.add(new ComputerRoom(20, 107, 24, false, true));

rooms.add(new ComputerRoom(18, 110, 18, false, true));

rooms.add(new ComputerRoom(20, 205, 24, false, true));

rooms.add(new BoardRoom(true, 15, 10, false, false));

rooms.add(new Room(118, 28, false, false));

rooms.add(new Room(124, 40, false, false));

}

}

---------------------------------------------------------------------------------------------------------------------------------------------------------

package info.hccis.room.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
import javax.swing.JOptionPane;

/**
* Utility class for generic program functions.
*
* @author BJ MacLean
* @since Feb 27, 2015
*/
public class Util {

public static final boolean DEBUGGING = false;
private static Scanner input = new Scanner(System.in);
private static boolean isGUI = false;

/**
* Get a scanner object.
*
* @return Scanner
* @since 20180226
* @author CIS1232
*/
public static Scanner getInput() {
return input;
}

/**
* Get input from the user using the appropriate input method
*
* @return String entered by user.
* @since 20180226
* @author CIS1232
*/
public static String getInputString(String output) {
if (isGUI) //use JoptionPane
{
return JOptionPane.showInputDialog(output);
} else {
display(output);
return input.nextLine();
}
}

/**
* Get input from the user using the appropriate input method
*
* @return int entered by user
* @since 20180226
* @author CIS1232
*/
public static int getInputInt(String output) {
if (isGUI) //use JoptionPane
{
return Integer.parseInt(JOptionPane.showInputDialog(output));
} else {
display(output);
return Integer.parseInt(input.nextLine());
}
}

/**
* Get input from the user using the appropriate input method
*
* @return double entered by user
* @since 20180226
* @author CIS1232
*/
public static double getInputDouble(String output) {
if (isGUI) //use JoptionPane
{
return Double.parseDouble(JOptionPane.showInputDialog(output));
} else {
display(output);
return Double.parseDouble(input.nextLine());
}
}
/**
* Get input from the user using the appropriate input method
*
* @param output
* @return boolean entered by user.
* @since 20180226
* @author CIS1232
*/
public static boolean getInputBoolean(String output) {

boolean answer = false;

if (isGUI) { //use JoptionPane
if (JOptionPane.showInputDialog(output).equalsIgnoreCase("Y")) {
answer = true;
}
} else {
display(output);
if (input.nextLine().equalsIgnoreCase("Y")) {
answer = true;
}

}
return answer;
}

/**
* Display output to the user using the appropriate input method
*
* @return void
* @since 20180226
* @author CIS1232
*/
public static void display(String output) {
if (isGUI) {
JOptionPane.showMessageDialog(null, output);
} else {
System.out.println(output);
}
}

/**
* Set the gui indicator. If gui then JOptionPane will be used.
*
* @author Brandon the great
* @param setter
*/
public static void setGUI(boolean setter) {
isGUI = setter;
}

/**
* Get today in the specified format
*
* @since 20180301
* @author BJM
* @param format The format for the date
*/
public static String getNow(String format) {
if (format.isEmpty()) {
format = "yyyy/MM/dd HH:mm:ss"; //Default
}
DateFormat dateFormat = new SimpleDateFormat(format);
Date date = new Date();
return dateFormat.format(date);
}
}

---------------------------------------------------------------------------------------------------------------------------------------------------------