-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwarehouse.ts
36 lines (28 loc) · 964 Bytes
/
warehouse.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* @packageDocumentation
* @category Shared
*/
import { Graph } from "./graph";
/** A Warehouse containing a graph and the maximum forkliftspeed */
export class Warehouse {
jsonPublicKeys = ["graph", "maxForkliftSpeed"];
/** The layout of the warehouse */
graph: Graph;
/** The maximum speed of forklifts in the warehouse in m/s */
maxForkliftSpeed: number;
constructor(graph: Graph, forkliftSpeed: number) {
this.graph = graph;
this.maxForkliftSpeed = forkliftSpeed;
}
/**
* Parses to a warehouse
* @param obj What should be parsed
* @returns A Warehouse if possible else null
*/
static parse(obj: any): Warehouse | null {
let parsedGraph: Graph | null = Graph.parse(obj.graph);
if (parsedGraph === null) return null;
if (typeof (obj.maxForkliftSpeed) !== "number") return null;
return new Warehouse(parsedGraph, obj.maxForkliftSpeed);
}
}