amazon 设计 5 hotel and restaurant reservation system

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

amazon 设计 5 hotel and restaurant reservation system的相关文章

amazon.设计1. tic tac toe

//不觉中 已经全力找工作好久好久了.大概有1年半了.身心疲惫,不要放弃.曙光快来了. 1.tic tac toe //http://www.ntu.edu.sg/home/ehchua/programming/java/JavaGame_TicTacToe.html 类似相关棋牌坐标对战游戏 一通百通 /** * Enumerations for the various states of the game */ public enum GameState { // to save as "G

amazon 设计 7 genial card game

package card; public class Game implements Runnable{ int numPlayers; int startNumber; //players and hands seperate so players can't change their cards Player player[] = new Player[numPlayers]; Hand hands[] = new Hand[numPlayers]; Card topCard; Deck d

amazon 设计 6 parking lot

public abstract class Vehicle { protected ParkingSpace pSpace; public abstract boolean park(ParkingLot pLot); public boolean unpark(ParkingLot pLot)P{ if(pSpace!=null){ pLot.reclaimFreeSpace(pSpace); return true; } return false; } } public class Cars

amazon 设计 11 chess

1 public class ChessPieceTurn { }; 2 public class GameManager { 3 void processTurn(PlayerBase player) { }; 4 boolean acceptTurn(ChessPieceTurn turn) { return true; }; 5 Position currentPosition; 6 } 7 8 public abstract class PlayerBase { 9 public abs

amazon 设计 10 puzzle.

class Edge { enum Type { inner, outer, flat } Piece parent; Type type; boolean fitsWith(Edge type) { }; // Inners & outer fit together. } class Piece { Edge left, right, top, bottom; // 90, 180, etc Orientation solvedOrientation = 90; } class Puzzle

amazon 设计 13 drawboard

public class Drawboard extends JFrame{ Graphics g; public static void main(String[] args){ Drawboard d = new Drawboard(); d.showUI(); } public void showUI(){ Graphics g ; this.setTitle("画图板"); this.setSize(600,600); this.setDefaultCloseOperation

MongoDB十二种最有效的模式设计【转】

持续关注MongoDB博客(https://www.mongodb.com/blog)的同学一定会留意到,技术大牛Daniel Coupal 和 Ken W. Alger ,从 今年 2月17 号开始,在博客上持续发表了 如何在MongoDB中设计数据库模式的方法.截止到今日(4月20号),12种模式设计的方法已全部与读者见面.本人认为,此系列文章,总结的非常全面,很多地方有首创性,涵盖的场景也很多,并且有理论总结,也有案例分析.文中分享的很多知识使人"如听仙乐耳暂明",开卷受益,常读

分布式系统(Distributed System)资料

这个资料关于分布式系统资料,作者写的太好了.拿过来以备用 网址:https://github.com/ty4z2008/Qix/blob/master/ds.md 希望转载的朋友,你可以不用联系我.但是一定要保留原文链接,因为这个项目还在继续也在不定期更新.希望看到文章的朋友能够学到更多. <Reconfigurable Distributed Storage for Dynamic Networks> 介绍:这是一篇介绍在动态网络里面实现分布式系统重构的paper.论文的作者(导师)是MIT

Java程序员应该了解的10个设计原则

引用: http://www.cnblogs.com/leehongee/archive/2012/03/18/2404760.html 面向对象设计原则是OOPS(Object-Oriented Programming System,面向对象的程序设计系统)编程的核心,但大多数Java程序员追逐像Singleton.Decorator.Observer这样的设计模式,而不重视面向对象的分析和设计.甚至还有经验丰富的Java程序员没有听说过OOPS和SOLID设计原则,他们根本不知道设计原则的好