Design an OO parking lot. What classes and functions will it have. It should say, full, empty and also be able to find spot for Valet parking. The lot has 3 different types of parking: regular, handicapped and compact.

Here is a quick start to get the gears turning...

ParkingLot is a class.

ParkingSpace is a class.

ParkingSpace has an Entrance.

Entrance has a location or more specifically, distance from Entrance.

ParkingLotSign is a class.

ParkingLot has a ParkingLotSign.

ParkingLot has a finite number of ParkingSpaces.

HandicappedParkingSpace is a subclass of ParkingSpace.

RegularParkingSpace is a subclass of ParkingSpace.

CompactParkingSpace is a subclass of ParkingSpace.

ParkingLot keeps array of ParkingSpaces, and a separate array of vacant ParkingSpaces in order of distance from its Entrance.

ParkingLotSign can be told to display "full", or "empty", or "blank/normal/partially occupied" by calling .Full(), .Empty() or .Normal()

Parker is a class.

Parker can Park().

Parker can Unpark().

Valet is a subclass of Parker that can call ParkingLot.FindVacantSpaceNearestEntrance(), which returns a ParkingSpace.

Parker has a ParkingSpace.

Parker can call ParkingSpace.Take() and ParkingSpace.Vacate().

Parker calls Entrance.Entering() and Entrance.Exiting() and ParkingSpace notifies ParkingLot when it is taken or vacated so that ParkingLot can determine if it is full or not. If it is newly full or newly empty or newly not full or empty, it should change the ParkingLotSign.Full() or ParkingLotSign.Empty() or ParkingLotSign.Normal().

HandicappedParker could be a subclass of Parker and CompactParker a subclass of Parker and RegularParker a subclass of Parker. (might be overkill, actually.)

In this solution, it is possible that Parker should be renamed to be Car.

Amazon Interview Question: Design an OO parking lot的更多相关文章

  1. Amazon Interview | Set 27

    Amazon Interview | Set 27 Hi, I was recently interviewed for SDE1 position for Amazon and got select ...

  2. amazon interview

    I'll be sitting for an Amazon interview in 3 months. Which website should I use to practice: SPOJ, H ...

  3. Core Java Interview Question Answer

    This is a new series of sharing core Java interview question and answer on Finance domain and mostly ...

  4. Amazon behavior question

    Amazon onsite behavior question[一亩三分地论坛面经版] - Powered by Discuz! http://www.1point3acres.com/bbs/thr ...

  5. an interview question(1)

    声明:本文为博主原创文章,未经博主允许不得转载. 以下是英文翻译: warnning: Copyright!you can't reprint this blog when you not get b ...

  6. shit LeetCode interview Question

    shit LeetCode interview Question https://leetcode.com/interview/1/ 有点晕,啥意思,没太明白,到底是要按什么排序呀? 去掉 标识符 不 ...

  7. JavaScript interview Question - Create a Array with two papameters without using loop!

    JavaScript interview Question - Create a Array with two papameters without using loop! JavaScript - ...

  8. Interview Question

    HDS(11.16.2015): How to design an non-stop website like Google or Amazon? What design patterns are y ...

  9. An interview question from MicroStrategy

    去年校招时的一道面试题,觉得蛮有意思,贴出来. Question: Spy start at a, during an interval he moves |b| to right when b &g ...

随机推荐

  1. spring IOC经典理解

    不多解释,直接上图片!

  2. 跨frame操作dom元素

    今天,一群友问到跨frame操作dom元素的问题.于是写了个demo,在此发表在博客里面,供其他同道中人参考! 创建child.html内容如下: <!DOCTYPE HTML PUBLIC & ...

  3. silverlight 画图InkPresenter

    <UserControl x:Class="SilverlightTest.PolygonTest" xmlns="http://schemas.microsoft ...

  4. Nginx启动SSL功能,并进行功能优化,你看这个就足够了

    一:开始Nginx的SSL模块 1.1 Nginx如果未开启SSL模块,配置Https时提示错误 nginx: [emerg] the "ssl" parameter requir ...

  5. JAVA多线程学习--哲学家就餐问题

    哲学家就餐问题是1965年由Dijkstra提出的一种线程同步的问题. 问题描述:一圆桌前坐着5位哲学家,两个人中间有一只筷子,桌子中央有面条.哲学家思考问题,当饿了的时候拿起左右两只筷子吃饭,必须拿 ...

  6. js定时器 特定时间执行某段程序的例子

    定时器想必大家并不陌生吧,在本文为大家详细介绍下js中是如何实现定时器的,具体原理及代码如下. 例子: $(function(){ var handler = function(){ //www.jb ...

  7. 基于Redis主从复制读写分离架构的Session共享

    1.搭建主从复制 第一步:将Redis拷贝到虚拟机上的指定文件夹内,此Redis作为主服务 第二步:将Redis拷贝到本机的指定文件夹内,此Redis作为从服务 第三步:修改主服务的配置文件(redi ...

  8. sql中的系统表sysobjects以及如何查看sql语句的执行时间

    使用sysobjects可以快速查看数据库中表.视图.存储过程.触发器.约束等的信息. 大牛文章:http://www.cnblogs.com/atree/p/SQL-Server-sysobject ...

  9. 重绘panel控件,实现panel的阴影效果

    最近想在项目中添加一个要有阴影的panel控件,找了好多资料,最后通过采用图片的方式实现了panel的阴影效果,效果图如下: 重绘代码如下: using System; using System.Co ...

  10. openerp经典收藏 深入理解对象(转载)

    深入理解对象(转载) 原文地址:http://shine-it.net/index.php/topic,2159.0.htmlhttp://blog.sina.com.cn/s/blog_57ded9 ...