-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
29 lines (26 loc) · 839 Bytes
/
main.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
import Point from "./point.ts";
import Device from "./device.ts";
import Station from "./station.ts";
const stations = [
new Station(new Point(0, 0), 10),
new Station(new Point(20, 20), 5),
new Station(new Point(10, 0), 12),
];
const devices = [
new Device(new Point(0, 0)),
new Device(new Point(100, 100)),
new Device(new Point(15, 10)),
new Device(new Point(18, 18)),
];
devices.map((device) => {
const maxPowerStation = device.getMaxPowerStation(stations);
if (maxPowerStation) {
console.log(
`Best link station for point ${device.location.x},${device.location.y} is ${maxPowerStation.location.x},${maxPowerStation.location.y} with power ${maxPowerStation.power}`,
);
} else {
console.log(
`No link station within reach for point ${device.location.x},${device.location.y}`,
);
}
});