當了一年的 Facebook Rotational Software Engineer 心得分享

一亩三分地论坛

 找回密码
 Sign Up 注册获取更多干货
E轮2.5亿美元融资
K12教育独角兽一起作业
北京-诚聘人工智能/教育/大数据岗
坐标湾区
Games Startup
招聘游戏开发工程师
游戏初创公司招聘工程师、UIUX Designer和游戏策划
码农求职神器Triplebyte:
不用海投
内推多家公司面试
把贵司招聘信息放这里
查看: 695|回复: 2
收起左侧

local公司一道OO设计题

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

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

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

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

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

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原则.
回复 支持 反对

使用道具 举报

本版积分规则

提醒:发帖可以选择内容隐藏,部分板块支持匿名发帖。请认真读完以下全部说明:

■隐藏内容方法: [hide=200]你想要隐藏的内容比如面经[/hide]
■意思是:用户积分低于200则看不到被隐藏的内容
■可以自行设置积分值,不建议太高(200以上太多人看不到),也不建议太低(那就没必要隐藏了)
■建议只隐藏关键内容,比如具体的面试题目、涉及隐私的信息,大部分内容没必要隐藏。
■微信/QQ/电子邮件等,为防止将来被骚扰甚至人肉,以论坛私信方式发给对方最安全。
■匿名发帖的板块和方法:http://www.1point3acres.com/bbs/thread-405991-1-1.html

关闭

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

手机版|小黑屋|一亩三分地论坛声明

custom counter

GMT+8, 2018-5-21 04:08

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

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