查看: 1636| 回复: 6
跳转到指定楼层
上一主题 下一主题
收起左侧

[找工就业] 公司面试题(java backend)-设计一个point-of-sale scanning API , 求帮忙

全局:

2021(4-6月)-CS硕士+fresh grad 无实习或全职 | 内推|大纽约地区 码农类General全职@ny base小公司

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

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
一家不到50人的小公司
. 1point3acres.com
Consider a store where items have prices per unit but also volume prices. For example, apples may be $1.00 each or 4 for $3.00.

Implement a point-of-sale scanning API that accepts an arbitrary ordering of products (similar to what would happen at a checkout line) and then returns the correct total price for an entire shopping cart based on the per unit prices or the volume prices as applicable.

Here are the products listed by code and the prices to use (there is no sales tax):
. Χ
Product Code | Price

A | $2.00 each or 4 for $7.00. 1point3acres.com

B | $12.00

C | $1.25 or $6 for a six pack

D | $0.15

There should be a top level point of sale terminal service object that looks something like the pseudo-code below. You are free to design and implement the rest of the code however you wish, including how you specify the prices in the system:

terminal.setPricing(...) terminal.scan("A") terminal.scan("C") ... etc. result = terminal.total

Here are the minimal inputs you should use for your test cases. These test cases must be shown to work in your program:

Scan these items in this order: ABCDABAA; Verify the total price is $32.40. Scan these items in this order: CCCCCCC; Verify the total price is $7.25. Scan these items in this order: ABCD; Verify the total price is $15.40.

评分

参与人数 1大米 +3 收起 理由
akdhfikbk + 3 欢迎分享你知道的情况,会给更多积分奖励!

查看全部评分


上一篇:Baidu USA 评价
下一篇:2.5年经验跳槽,如何分配简历各段经历篇幅
🔗
zhang5690889 2021-5-25 09:33:29 | 只看该作者
全局:
别在小公司浪费时间,题没什么价值
回复

使用道具 举报

全局:
这种题是直接写个code就完了还是需要形成一个小工程文件
回复

使用道具 举报

🔗
lllxin37 2021-5-25 12:44:54 | 只看该作者
全局:

  1. class Product {
  2.   private String productName; // or productCode. 1point3acres.com
  3. -baidu 1point3acres
  4.   private double unitPrice;
  5.   private double bulkPrice;. Χ
  6.   private int bulkUnits;

  7. }. .и

  8. public class ProductSale {
  9.   Map<String, Product> products; // key: productName or code, value: Product
  10. . 1point 3 acres
  11.   public double calculatePrice(String shoppingList) {
  12.         /* separate shopping list to each item

  13.             put into Map<String, Integer> key as productName value as counts. 1point3acres

  14.             go iterates each key inside Map.google  и

  15.              always try with bulkPrice/bulkUnits first. then apply unitPrice
  16.              sums up
  17. . Waral dи,


  18.              return total;

  19.        */

  20.   }. From 1point 3acres bbs

  21. }
  22. . 1point3acres

复制代码


回复

使用道具 举报

🔗
ND0406 2021-5-25 13:12:51 来自APP | 只看该作者
全局:
map存上coupon的细节,然后每次加一个product就去map搜索一下coupon细节 搜索到了看一下满足不满足细节 满足则修改购物车信息。-baidu 1point3acres
总的来说就是需要两个map 加一个total price.
一个map是 key product value个数 对就是你的购物车
一个map是 key product value list of coupon

.
回复

使用道具 举报

🔗
 楼主| caezy 2021-5-26 09:27:52 | 只看该作者
全局:
谢谢各位!用java写完之后被告知要用php写
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

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