Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi can you help me in these method ? java eclipse Hotel class package donottouch; import java.util.ArrayList; public class Hotel { private String name; private

Hi

can you help me in these method ? java eclipse

Hotel class

package donottouch;

import java.util.ArrayList;

public class Hotel {

private String name; private int numberOfFloors; private ArrayList rooms; public Hotel(String name, int numberOfFloors) { this.name = name; this.numberOfFloors = numberOfFloors; rooms = new ArrayList(); } public String getName() { return name; } public int getNumberOfFloors() { return numberOfFloors; } public Room getRoomAt(int index) { return rooms.get(index); } public void addRoom(Room room) { rooms.add(room); } public int getNumOfRooms() { return rooms.size(); } public String toString() { String ans = String.format("Name: %s, Number of floors: %d%n", name, numberOfFloors); for (Room r : rooms) ans += String.format("%s%n", r.toString()); return ans; } }

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

package donottouch;

public class DoubleRoom extends Room implements Wifi{

private int numberOfBeds; private String wifiName; private String wifiPass; private boolean hasWifi; private int wifiEncryption; public DoubleRoom(int floorNum, boolean beachView, int numberOfBeds, boolean hasWifi) { super(floorNum, beachView); this.numberOfBeds = numberOfBeds; this.hasWifi = hasWifi; } public int getNumberOfBeds() { return numberOfBeds; }

@Override public String getWifiName() { return wifiName; }

@Override public String getWifiPass() { return wifiPass; }

@Override public boolean hasWifi() { return hasWifi; }

@Override public void setWifiName(String name) { wifiName = name; }

@Override public void setWifiPass(String pass) { wifiPass = pass; }

@Override public int getWifiEncryption() { return wifiEncryption; }

@Override public void setWifiEncryption(int encrypt) { wifiEncryption = encrypt; } public String toString() { String ans = "Type: Double, Floor number: " + getFloorNumber() + ", Beach view: " + hasBeachView() + ", Number of beds: " + numberOfBeds + ", Has wifi: " + hasWifi; if (hasWifi) ans += ", Wifi name: " + wifiName + ", Wifi pass: " + wifiPass + ", Wifi Encryption: " + ((wifiEncryption == Wifi.WPA_ENCRYPTION)? "WPA" : "WPA2"); return ans; }

}

image text in transcribed

public static int getNumberofDoubleRooms (Hotel hotel) {//T0D0 2: make this method return the number of Double rooms inside a given hotel return -1;//replace this } public static Hotel getSingleOnly Hotel (Hotel hotel) {//TODO 3: make this method return a new hotel with the same name, and number of floors as the given hotel.//However, the new hotel should ONLY contain the single rooms (no double rooms).//return null.//replace this } public static Wifi getNewRoomWithWifi() {//TODO 4: make this method return a new room with the following Wifi details://(You may fill the other details with your own random information)/* * *Wifi name: Netgear. *Wifi pass: abcdefg *Wifi encryption: WPA */

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions