Requirements
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class main {
//new RoomType(“Executive studio”,210,210,2,20,17))
public static void main(String args[])
ArrayList<Hotel> hotel = new ArrayList<Hotel>();
hotel.add(new Hotel(“El Grando”, “Lakeside Drive, San Diego”, 3,3));
hotel.add(new Hotel(“Ivory Tower”, “Pinehill Road, Boston”, 4,3));
hotel.add(new Hotel(“Elite”, “Federation Drive, Washington DC”, 5,4));
hotel.add(new Hotel(“Fleabox Motel”, “Wrong Side of the Tracks Road, Cleveland”, 1,1))
hotel.get(0).setRoomType(new RoomType(“Executive studio”,210,210,2,20,17));
hotel.get(0).setRoomType(new RoomType(“Standard studio”,180,180,2,30,10));
hotel.get(0).setRoomType(new RoomType(“Family room”,220,200,4,10,2));
hotel.get(1).setRoomType(new RoomType(“Executive studio”,235,235,2,5,3));
hotel.get(1).setRoomType(new RoomType(“Standard studio”,205,205,2,12,0));
hotel.get(1).setRoomType(new RoomType(“Super-sized family room“,350,350,6,4,1));
hotel.get(2).setRoomType(new RoomType(“Ultra-luxury suite“,890,8900,2,5,3));
hotel.get(2).setRoomType(new RoomType(“Elitist Studio”,1400,1400,1,1,1));
hotel.get(2).setRoomType(new RoomType(“Penthouse Apartment”,1200,1200,4,3,2));
hotel.get(2).setRoomType(new RoomType(“Gold-plated Luxury“,1799,1799,2,10,8));
hotel.get(3).setRoomType(new RoomType(“Sardine Room”,80,55,8,120,25));
Scanner sc = new Scanner(System.in);
int flag = 0;
System.out.println(“Welcome to the Hotel Recommendation Systemn” +
“Developed by [Enter Your name Here], student ID [Enter your ID] for ITECH1000 Semester 1 2017”);
while (flag!=5)
System.out.println(“MAIN MENUn” +
“Please select an option from the menu:n” +
“1. Display all hotelsn” +
“2. Find cheapest roomn” +
“3. Set a sale pricen” +
“4. Find rooms matching criterian” +
“5. Exit System”);
flag=sc.nextInt();
switch(flag)
{
case 1:
for (Hotel h : hotel)
{
System.out.print(“============================================================n”);
System.out.println(h.toString());
System.out.print(“============================================================n”);
for (RoomType r : h.roomTypes)
System.out.println(r.toString());
break;
case 2:
System.out.print(“The cheapest rate available in any hotel is at “);
Hotel h1=null;
RoomType r1 = null;
for (Hotel h: hotel)
{
r1 = h.roomTypes.get(0);
int min = r1.getRegularPrice();
for(RoomType r : h.roomTypes)
if(r.regulaarPrice<min)
{
h1 = h;
r1=r;
System.out.println(h1.toString());
System.out.println(r1.toString());
break;
case 3:
String name =””;
while(!name.equalsIgnoreCase(“q”))
System.out.println(“Setting sale price”);
System.out.println(“To exit press q”);
Scanner s = new Scanner(System.in);
System.out.print(“Enter hotel name:”);
name = s.nextLine();
if(!name.equals(null))
for(Hotel h : hotel)
if(h.getName().contains(name))
int i=0;
int idx;
for(i =0; i<h.roomTypes.size();i++)
System.out.println(i+1+”: “+h.roomTypes.get(i).getName());//only name
boolean pass=false;
while(!pass)
System.out.print(“Enter room type number: “);
idx = sc.nextInt();
if(idx>=1 && idx<=i)
System.out.println();
RoomType r2 = h.roomTypes.get(idx-1);//-1
System.out.println(r2.toString());
Scanner s1 = new Scanner(System.in);
while(!pass)
System.out.print(“Enter sale price: $”);
int price = s1.nextInt();
if(price>=(r2.getSalePrice()/2) && price<=r2.getSalePrice())
h.roomTypes.get(idx-1).setSalePrice(price);
pass=true;
System.out.println(“Sale price updated.”);
System.out.println(“Value must be between “+(r2.getSalePrice()/2)+” and “+r2.getSalePrice()+”. Please try again”);
System.out.print(“Value must be between 1 and “+i+”.”) }
else if (name.contains(“”))
System.out.println(“Invalid entry!!”);
System.out.println(“No hotel matches that name. Please try again.”);
break;
case 4:
boolean pass2 = false;
while(!pass2)
System.out.println(“Please enter the criteria which you require.”);
Scanner s1 = new Scanner(System.in);
System.out.print(“nMinimum occupancy required: “);
int occupy = s1.nextInt();
System.out.print(“nMinimum star rating required: “);
int rating = s1.nextInt();
System.out.print(“nMaximum daily price you are willing to pay: “);
int cost = s1.nextInt();
for (Hotel h : hotel)
if(h.getStarRating()>=rating)
for (RoomType r : h.roomTypes)
if(r.getMaximumOccupancy()>=occupy && r.getRegularPrice()<=cost)
System.out.print(“============================================================n”);
System.out.println(h.toString());
System.out.print(“============================================================n”)
System.out.println(r.toString())
import java.util.ArrayList;
import java.util.List;
public class Hotel {
String name;
String address;
int starRatiing;
ArrayList<RoomType> roomTypes;
public Hotel(String _name, String _address, int _starRating, int _numRoomTypes)
this.name = _name;
this.address = _address;
this.starRatiing = _starRating;
roomTypes = new ArrayList<RoomType>(_numRoomTypes);
public String getName()
return this.name;
public String getAddress()
return this.address;
public int getStarRating()
return this.starRatiing;
public int getNumRoomTypes()
return this.roomTypes.size();//parameter value
public RoomType getRoomType(int index)
return this.roomTypes.get(index);
public boolean setRoomType(RoomType _roomType)
if(!_roomType.equals(null))
this.roomTypes.add(_roomType);
return true;
String name;
int regulaarPrice;
int salePrice;
int maximumOccupancy;
int numberOfRooms;
int numberOfVacancies;
public RoomType(String _name, int _regularPrice, int _salePrice, int _maximumOccupancy, int _numberOfRooms, int _numberOfVacancies
this.name = _name;
this.maximumOccupancy = _maximumOccupancy;
this.regulaarPrice = _regularPrice;
this.salePrice = _salePrice;
this.numberOfRooms = _numberOfRooms;
this.numberOfVacancies = _numberOfVacancies;
public String getName()
return this.name;
public int getRegularPrice()
return this.regulaarPrice;
public int getSalePrice()
return this.salePrice;
public void setSalePrice(int newPrice)
public int getMaximumOccupancy()
return this.maximumOccupancy;
c int getNumberOfRooms()
return this.numberOfRooms;
public int getNumberofVacancies()
return this.numberOfVacancies;
public String toString()
return “Room type: “+this.name+”n Maximum occupancy: “+this.maximumOccupancy+”n”
+ “Regular price $” +this.regulaarPrice+” Sale price $”+this.salePrice+”n”;
References
Jayaraman, S., Jayaraman, B., & Lessa, D. (2016). Compact visualization of Java program execution. Software: Practice and Experience.
Kothari, S., 2015. Comprehension-Driven Program Analysis (CPA) for Malware Detection in Android Phones. IOWA STATE UNIV AMES.
Ruiz, M., & Arroyo, C. (2016). JOLer: una aplicación Java de escritorio para simular el modelo de juicios de aprendizaje de Weaver y Kelemen. Anales de Psicología, 32(3), 893-898.
Varier, K. M., Sankar, V., & Gangadathan, M. P. (2017). TrackEtching–A Java based code for etched track profile calculations in SSNTDs. Computer Physics Communications.
Elaasar, M., & Badreddin, O. (2016, October). Modeling meets programming: a comparative study in model driven engineering action languages. In International Symposium on Leveraging Applications of Formal Methods (pp. 50-67). Springer International Publishing.
Funabiki, N., Dake, M., Zaw, K. K., & Kao, W. C. (2016, November). A Workbook Design for Fill-in-Blank Problems in Java Programming Learning Assistant System. In International Conference on Broadband and Wireless Computing, Communication and Applications (pp. 331-342). Springer International Publishing.