Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day195:实现一个简单的仓储系统,可以不断转入和转出货物,货物最多有两层子类目,数字代表该子类目转入/转出的数量。转出时不能出现爆仓情况。 #1012

Open
Genzhen opened this issue Dec 9, 2020 · 0 comments
Labels

Comments

@Genzhen
Copy link
Collaborator

Genzhen commented Dec 9, 2020

/*
 * cargo 说明:
 * key代表类目/子类目名称
 * value 为 number时,代表这个类目的数量,为object 时,代表下一层货物的集合,最多嵌套两层
 * {
 *  productA:{  // 代表货物的类目名称
 *    a:1, // 1 代表子类目 a 的数量
 *    b:2,
 *    c:{   // c 代表货物的子类名称
 *      c1:1, // c1代表货物的子类名称
 *    }
 *   },
 *  productB:{
 *      e:6
 *   }
 * }
 *
 * 爆仓情况:如转入 {productA:{a:3,c:1}} 转出 {productA:{a:4}},就会发生子类目a爆仓,此时要返回报错。
 *
 */

class Depository {
  /**
   * @param options
   */
  constructor(options) {}
  // 转入货物
  transferIn(cargo) {}
  // 转出货物
  transferOut(cargo) {}
}

每日一题会在下午四点在交流群集中讨论,五点小程序中更新答案
欢迎大家在下方发表自己的优质见解
二维码加载失败可点击 小程序二维码

扫描下方二维码,收藏关注,及时获取答案以及详细解析,同时可解锁800+道前端面试题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant