there I write down the restaurant system.
public class TimeSpan { Date date; String start; String end; } public class Table { int tableid; String type; HashMap<Date,HashMap<String,String>> reserved; public boolean isFitToRequest(Request ts){ return false; } } public class Request { String name; String phone_number; TimeSpan ts; Date date; int seats; public boolean isFitToRequest(Table table){ return false; } } public class Restaurant { Rinfo rInfo; TableManager tm; } class Rinfo{ String name; String add; String phoneno; } public class TableManager { HashMap<Integer,Table> map_tablse; ArrayList<Table> tables; ArrayList<Request> waitingList; private int numofTable; private int numberofLarge; private int numberofMedium; private int numberofSmall; public TableManager(){ } public synchronized void reserveResult(Request r){ if(processRequest(r)){ System.out.println("Successed!"); }else{ System.out.println("You are on the waiting list"); } } private boolean processRequest(Request r){ for(Table table : tables){ if(r.isFitToRequest(table)){ update(table,r); return true; } else continue; } return false; } public void update(Table table, Request r){} }
时间: 2024-10-12 17:41:48