File
Metadata
selector |
app-utilities |
styleUrls |
utilities.component.css |
templateUrl |
utilities.component.html |
empty_bucket
|
empty_bucket: number
|
Default value: 2
|
The weight value of an empty bucket
|
filled_bucket
|
filled_bucket: number
|
Default value: 10
|
The weight value of a bucket filled with items
|
Math
|
Math: Math
|
Default value: Math
|
The Number of Items is calculated by taking the weight of the items excluding the bucket dividing it by the weight of a single item. Math object to make use of the floor function
|
result
|
result: () => string
|
single_item
|
single_item: number
|
Default value: 1
|
The weight value of an individual item
|
import { Component, OnInit, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
@Component({
selector: 'app-utilities',
templateUrl: './utilities.component.html',
styleUrls: ['./utilities.component.css']
})
export class UtilitiesComponent implements OnInit {
// Filled bucket - empty bucket = weight of all items
// weight of all items / single item weight = num items
/**
* The weight value of an individual item
*/
single_item = 1.0;
/**
* The weight value of an empty bucket
*/
empty_bucket = 2.0;
/**
* The weight value of a bucket filled with items
*/
filled_bucket = 10.0;
/** The Number of Items is calculated by taking the weight of the items excluding the bucket
* dividing it by the weight of a single item.
*/
/**
* Math object to make use of the floor function
*/
Math: Math = Math;
result = (() => {
if (this.empty_bucket > this.filled_bucket) {
return 'Empty bucket cannot weigh more than a filled bucket';
}
if (!this.empty_bucket || !this.filled_bucket || !this.single_item) {
return 'Weight inputs cannot be empty';
}
if (this.empty_bucket <= 0 || this.filled_bucket <= 0 || this.single_item <= 0 ) {
return 'Weight value must be a positive value';
}
return 'Number of items: ' + Math.floor((this.filled_bucket - this.empty_bucket) / this.single_item);
});
/**
* @ignore
*/
constructor() { }
/**
* @ignore
*/
ngOnInit() {
}
}