Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started