import { Item } from "./item"; export class safe { constructor( private items: Array, ) { this.items = []; } addItem(item: Item): void { this.items.push(item); } takeOutItem(id: number): Item { const item = this.items.filter(function (item) { return id == item.id; })[0]; this.items = this.items.filter(function (item) { return id !== item.id; }); return item; } calculateInsuranceValueOfAllItems(): number { return this.items.reduce((sum, item) => sum + item.insuranceValue, 0); } getAllInsuranceValues(): number[] { return this.items.map(item => item.insuranceValue); } }