D3: parking lot

Real world objects are handled very similarly to software object oriented design.  Suppose 
you are designing an object oriented design for a parking lot:
1.  What are your goals?  For example: !gure out if a parking spot is taken, !gure out how 
many cars of each type are in the parking lot, look up handicapped spots, etc.
2.  Now, think about the core objects (Car, ParkingSpot, ParkingLot, ParkingMeter, etc—
Car has di#erent subclasses, and ParkingSpot is also subclassed for handicapped spot).
3.  Have we missed anything? How will we represent parking restrictions based on time 
or payment?  Perhaps, we’ll add a class called Permission which handles di#erent pay-
ment systems.  Permission will be sub-classed into classes PaidPermission (fee to park) 
and FreeParking (open parking).  ParkingLot will have a method called GetPermission 
which will return the current Permission object based on the time.
4.  How will we know whether or not a car is in a spot?  Think about how to represent the 
data so that the methods are most e$cient.

转载于:https://www.cnblogs.com/xishibean/archive/2013/03/06/2951281.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值