import java.rmi.Naming; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; public class ServerOperation extends UnicastRemoteObject implements RMIInterface{ protected ServerOperation() throws RemoteException {} public String[] display(String city) throws RemoteException{ String[] cityName = {"city1", "city1", "city1", "city2", "city2"}; String[] hotelName = {"hotel1", "hotel2", "hotel3", "hotel1", "hotel2"}; int[] emptyRooms = {10, 15, 0, 0, 150}; String [] hotelList = new String[10]; int j=0; for(int i=0; i0)){ hotelList[j]=hotelName[i]; j++; } } return hotelList; } // We can also use an array in the implementation of this function public String booking(String city, String hotel) throws RemoteException{ String[] cityName = {"city1", "city1", "city1", "city2", "city2"}; String[] hotelName = {"hotel1", "hotel2", "hotel3", "hotel1", "hotel2"}; int[] emptyRooms = {10, 15, 0, 0, 150}; for(int i=0; i0)){ emptyRooms[i]=emptyRooms[i]-1; return "reserved"; } } return "failed"; } public static void main(String[] args){ try { Naming.rebind("//localhost/MyServer", new ServerOperation()); System.out.println("Server ready"); } catch (Exception e) { System.err.println("Server exception: " + e.toString()); e.printStackTrace(); } } }