| 123456789101112131415161718192021222324252627282930 |
- import { nanoid } from 'nanoid'
- import { toLiquid } from './utils.js'
-
- class Container {
- constructor({ l, w, h }, level = 0, label, id = nanoid()) {
- this._id = id //=> "V1StGXR8_Z5jdHi6B-myT"
- this._label = label ? label : ''
- this.l = l
- this.w = w
- this.h = h
- this.level = level
- }
- get id() {
- return this._id
- }
- get label() {
- return this._label
- }
- get liquidVolumeCapacity() {
- return toLiquid(this.l * this.w * this.h)
- }
- get liquidVolumeFilled() {
- return toLiquid(this.l * this.w * this.level)
- }
- get liquidVolumeRemaining() {
- return this.liquidVolumeCapacity - this.liquidVolumeFilled
- }
- }
-
- export { Container }
|