Question: Given the Code below, how to unit test all 5 cases asked that are described in the //comments: // verify the type of room to

Given the Code below, how to unit test all 5 cases asked that are described in the //comments:

// verify the type of room to set the corresponding price

// loop over the array of rooms to search an available room of passed type

// verify the type & availability of current room

// return reference to found room

// no room was found, return null

Room.java

public class Room { private String type; private double price; private boolean availability; public Room(String type) { // verify the type of room to set the corresponding price type = type.toLowerCase(); if (type.equals("double")) { price = 90; } else if (type.equals("queen")) { price = 110; } else if (type.equals("king")) { price = 150; } else { throw new IllegalArgumentException("No room of type '" + type + "' can be created"); } this.type = type; availability = true; } public String getType() { return type; } public double getPrice() { return price; } public boolean getAvailability() { return availability; } public void changeAvailability() { availability = ! availability; } public static Room findAvailableRoom(Room [] rooms, String type) { // loop over the array of rooms to search an available room of passed type for (int i=0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!