一亩三分地论坛

 找回密码
 获取更多干货,去instant注册!

扫码关注一亩三分地公众号
查看: 224|回复: 2
收起左侧

local公司一道OO设计题

[复制链接] |试试Instant~ |关注本帖
teargone08 发表于 2015-10-28 13:39:55 | 显示全部楼层 |阅读模式

2015(10-12月) 码农类 硕士 全职@local company - 猎头 - 其他 |Other在职跳槽

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看,没有帐号?获取更多干货,去instant注册!

x
今天收到一个面试作业题,需48小时返回。大伙看看有没有好的解决方案,谢谢!
Programming Assessment
Guidelines
Thegoal of this assessment is to validate your ability to create a high quality, productionready application that meets the stated requirements. Please consider programmingbest practices as you design your solution, including good Object Oriented principlesand proper coding grammar.  
You willbe graded not only on whether your application produces the correct output, butalso to what degree your solution is extensible and maintainable.


1.       It is expectedthat the completed project can be copied to a development machine with VisualStudio installed and compiled/run without modification.  
2.       If additionalsteps are required to compile and run the solution, instructions must beprovided.  A console application issufficient.  
3.       No user inputshould be required to produce the transaction output.  

ProblemStatement
Basicsales tax is applicable at a rate of 10% on all goods, except books, food, andmedical products that are exempt. Import duty is an additional sales taxapplicable on all imported goods at a rate of 5%, with no exemptions. When Ipurchase items I receive a receipt which lists the name of all the items andtheir price (including tax), finishing with the total cost of the items, and thetotal amounts of sales taxes paid.  The rounding rules for sales tax arethat for a tax rate of n%, a shelf price of p contains (np/100 rounded up tothe nearest 0.05) amount of sales tax. Write an application that prints out thereceipt details for these shopping baskets.
Input
Shopping Basket 1:
1 book at 12.49
1 music CD at 14.99
1 chocolate bar at 0.85
Shopping Basket 2:
1 imported box of chocolates at 10.00
1 imported bottle of perfume at 47.50
Shopping Basket 3:
1 imported bottle of perfume at 27.99
1 bottle of perfume at 18.99
1 packet of headache pills at 9.75
1 imported box of chocolates at 11.25
. more info on 1point3acres.com
stellari 发表于 2015-10-28 23:29:10 | 显示全部楼层
我想你可以用Strategy模式,来将“10%”和“免税”实现成两种不同的“策略”,这样所有的商品都必使用这两种策略之一。至于Imported,因为是在上述的两种策略的基础上叠加的税,所以可以再加用Decorator模式,向10%和免税二策略上添加Imported功能。
.鐣欏璁哄潧-涓浜-涓夊垎鍦
这样做主要是为了考虑到今后的扩展性。比如,以后有可能会开始对图书征5%的税。或者有采取有起征点的税法(比如10元以下不征税,10元以上征10%之类的)。无论出现什么税法,只要将新的税法实现成一个新的Strategy就可以了
回复 支持 反对

使用道具 举报

 楼主| teargone08 发表于 2015-10-29 05:18:50 | 显示全部楼层
好建议,3X.还有重要一点是solid原则.
回复 支持 反对

使用道具 举报

本版积分规则

请点这里访问我们的新网站:一亩三分地Instant.

Instant搜索更强大,不扣积分,内容组织的更好更整洁!目前仍在beta版本,努力完善中!反馈请点这里

关闭

一亩三分地推荐上一条 /5 下一条

手机版|小黑屋|一亩三分地论坛声明 ( 沪ICP备11015994号 )

custom counter

GMT+8, 2016-12-4 05:57

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

快速回复 返回顶部 返回列表