Amazon Interview Question: Design an OO parking lot
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的更多相关文章
- Amazon Interview | Set 27
Amazon Interview | Set 27 Hi, I was recently interviewed for SDE1 position for Amazon and got select ...
- amazon interview
I'll be sitting for an Amazon interview in 3 months. Which website should I use to practice: SPOJ, H ...
- Core Java Interview Question Answer
This is a new series of sharing core Java interview question and answer on Finance domain and mostly ...
- Amazon behavior question
Amazon onsite behavior question[一亩三分地论坛面经版] - Powered by Discuz! http://www.1point3acres.com/bbs/thr ...
- an interview question(1)
声明:本文为博主原创文章,未经博主允许不得转载. 以下是英文翻译: warnning: Copyright!you can't reprint this blog when you not get b ...
- shit LeetCode interview Question
shit LeetCode interview Question https://leetcode.com/interview/1/ 有点晕,啥意思,没太明白,到底是要按什么排序呀? 去掉 标识符 不 ...
- 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 - ...
- Interview Question
HDS(11.16.2015): How to design an non-stop website like Google or Amazon? What design patterns are y ...
- An interview question from MicroStrategy
去年校招时的一道面试题,觉得蛮有意思,贴出来. Question: Spy start at a, during an interval he moves |b| to right when b &g ...
随机推荐
- JAVA多线程通信
JAVA多线程通信 package com.frank.thread; /** * author:pengyan * date:Jun 16, 2011 * file:ProducerAndCusto ...
- YCM的安装与配置
花了好几天的时间,总算把YCM装上了.期间遇到了各种问题,主要还是因为刚进linux,对linux环境不熟, 命令资料等查了半天.当然,YCM也普遍被认为是一种安装配置复杂,但使用起来超简单的插件. ...
- MySQL事务机制
事务机制的特性通常被概括为"ACID原则" A(Atomic) 原子性: 构成一个事务的所有语句应该是一个独立的逻辑单元,要么全部执行成功, 要么一个都不成功, 你不能只执行他们当 ...
- C# 汉字转拼音(转)
(一)将汉字转化成全拼代码: private void button1_Click(object sender, EventArgs e) { this.textBox2.Text = Hz2Py.C ...
- git记住用户名密码
git config --global credential.helper store
- 用PHP判断客户端是否是手机
<?php function isMobile(){ $useragent = isset($_SERVER['HTTP_USER_AGENT'])? $_SERVER['HTTP_USER_A ...
- 《零成本实现Web自动化测试--基于Selenium》 第四章 Selenium 命令
Selenium 命令,通常被称为Selenese,由一系列运行测试案例所需要的命令构成.按顺序排列这些命令就构成了测试脚本. 一. 验证颜面元素 1.Assertion或者Verification ...
- 每日一“酷”之heapq
作用:heapq模块实现一个适用于Python列表的最小堆排序算法 堆(heap)是一个属性数据结构,其中子节点与父节点是一种有序关系.二叉堆是一种特殊的堆,二叉堆是完全二元树(二叉树)或者是近似完全 ...
- Makefile之wildcard
1.wildcard : 扩展通配符2.notdir : 去除路径3.patsubst :替换通配符 例子:建立一个测试目录,在测试目录下建立一个名为sub的子目录$ mkdir test$ cd t ...
- UIActivityIndicatorView的使用
class ViewController: UIViewController,UIActionSheetDelegate{ @IBOutlet weak var label1: UILabel! @I ...