Skip to content

Commit 15f5273

Browse files
committed
Update index.ts
1 parent a5f0a00 commit 15f5273

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

design-underground-system/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
export default class UndergroundSystem {
2-
id2info = new Map<number, [string, number]>();
3-
station2time = new Map<string, number[]>();
2+
#id2info = new Map<number, [string, number]>();
3+
#station2time = new Map<string, number[]>();
44
constructor() {
55
}
66

77
checkIn(id: number, stationName: string, t: number): void {
88
const info: [string, number] = [stationName, t];
9-
this.id2info.set(id, info);
9+
this.#id2info.set(id, info);
1010
}
1111

1212
checkOut(id: number, stationName: string, t: number): void {
13-
const info = this.id2info.get(id);
13+
const info = this.#id2info.get(id);
1414
if (info) {
1515
const key = JSON.stringify([info[0], stationName]);
16-
const time = this.station2time.get(
16+
const time = this.#station2time.get(
1717
key,
1818
) ?? [];
1919
time.push(t - info[1]);
20-
this.station2time.set(key, time);
20+
this.#station2time.set(key, time);
2121
} else {
2222
throw Error("accident");
2323
}
2424
}
2525

2626
getAverageTime(startStation: string, endStation: string): number {
2727
const key = JSON.stringify([startStation, endStation]);
28-
const time = this.station2time.get(
28+
const time = this.#station2time.get(
2929
key,
3030
);
3131
if (!time) throw Error("accident");

0 commit comments

Comments
 (0)