Skip to content

Commit

Permalink
[cps] [subway] defineStation
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Aug 24, 2024
1 parent b8b4133 commit 95adddd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
4 changes: 1 addition & 3 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
[cps] [subway] `defineStation`

[cps] [subway] `defineLine` -- take a ordered list of stations
[cps] [subway] `defineLine` -- take an ordered list of stations

[cps] [subway] define `bostonSubway`

Expand Down
11 changes: 10 additions & 1 deletion src/cps/subway/Subway.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export type LineId = string
export type StationId = string

export type Position = string
export type Position = { x: number; y: number }

export type Line = {
id: LineId
Expand All @@ -27,3 +27,12 @@ export function createSubway(name: string): Subway {
stationMap: new Map(),
}
}

export function defineStation(
subway: Subway,
stationId: StationId,
lineIds: Array<LineId>,
position: Position,
): void {
///
}
35 changes: 19 additions & 16 deletions src/cps/subways/bostonSubway.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createSubway } from "../subway/index.js"
import { createSubway, defineStation } from "../subway/index.js"

export const bostonSubway = createSubway("boston-subway")

Expand All @@ -7,20 +7,23 @@ export const bostonSubway = createSubway("boston-subway")
// defineLine(bostonSubway, "orange-line")
// defineLine(bostonSubway, "blue-line")

// defineStation(bostonSubway, "airport", ["blue-line"], 4.0, 1.0))
// defineStation(bostonSubway, "aquarium", ["blue-line"], 3.75, 0.1))
// defineStation(bostonSubway, "wood-island", ["blue-line"], 5.0, 2.0))
// defineStation(bostonSubway, "state", ["blue-line", "orange-line"], 3.1, -0.75))
// prettier-ignore
{
defineStation(bostonSubway, "airport", ["blue-line"], {x: 4.0, y: 1.0})
defineStation(bostonSubway, "aquarium", ["blue-line"], {x: 3.75, y: 0.1})
defineStation(bostonSubway, "wood-island", ["blue-line"], {x: 5.0, y: 2.0})
defineStation(bostonSubway, "state", ["blue-line", "orange-line"], {x:3.1, y:-0.75})

// defineStation(bostonSubway, "park-street", ["green-line", "red-line"], 2.5, -0.5))
// defineStation(bostonSubway, "government-center", ["green-line", "blue-line"], 2.9, -0.25))
// defineStation(bostonSubway, "copley-square", ["green-line",], 1.0, -1.0))
// defineStation(bostonSubway, "boston-u", ["green-line",], -1.0, -1.0))
// defineStation(bostonSubway, "north-station", ["green-line", "orange-line"], 2.5, 0.75))
// defineStation(bostonSubway, "haymarket", ["orange-line" "green-line",], 2.75, 0.5))
defineStation(bostonSubway, "park-street", ["green-line", "red-line"], {x: 2.5, y:-0.5})
defineStation(bostonSubway, "government-center", ["green-line", "blue-line"], {x:2.9,y: -0.25})
defineStation(bostonSubway, "copley-square", ["green-line",], {x:1.0, y: -1.0})
defineStation(bostonSubway, "boston-u", ["green-line",], {x:-1.0, y:-1.0})
defineStation(bostonSubway, "north-station", ["green-line", "orange-line"], {x:2.5, y:0.75})
defineStation(bostonSubway, "haymarket", ["orange-line" ,"green-line",], {x: 2.75, y:0.5})

// defineStation(bostonSubway, "south-station", ["red-line"], 3.0, -1.0)
// defineStation(bostonSubway, "washington", ["red-line", "orange-line"], 2.75, -0.75)
// defineStation(bostonSubway, "kendall-square", ["red-line"], 1.0, 0.0)
// defineStation(bostonSubway, "central-square", ["red-line"], -1.0, 0.0)
// defineStation(bostonSubway, "harvard-square", ["red-line"], -2.0, 1.0)
defineStation(bostonSubway, "south-station", ["red-line"], {x: 3.0, y:-1.0})
defineStation(bostonSubway, "washington", ["red-line", "orange-line"], {x:2.75, y:-0.75})
defineStation(bostonSubway, "kendall-square", ["red-line"], {x:1.0, y:0.0})
defineStation(bostonSubway, "central-square", ["red-line"], {x:-1.0, y:0.0})
defineStation(bostonSubway, "harvard-square", ["red-line"], {x:-2.0, y:1.0})
}

0 comments on commit 95adddd

Please sign in to comment.