From 80dee944808510d3dbfbe99c309f6b103cecdb3b Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 13:25:33 +0900
Subject: [PATCH 01/25] =?UTF-8?q?docs:=20README.md=20=EA=B5=AC=ED=98=84?=
=?UTF-8?q?=ED=95=A0=20=EA=B8=B0=EB=8A=A5=20=EB=AA=A9=EB=A1=9D=20=EC=B6=94?=
=?UTF-8?q?=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 253 ++----------------------------------------------------
1 file changed, 7 insertions(+), 246 deletions(-)
diff --git a/README.md b/README.md
index d6299154c..450a9183e 100644
--- a/README.md
+++ b/README.md
@@ -5,249 +5,10 @@
## ๐ ๊ธฐ๋ฅ ์๊ตฌ์ฌํญ
-> ํ๋ฆฌ์ฝ์ค 3์ฃผ์ฐจ ๋ฏธ์
์์ ์ฌ์ฉํ ์ฝ๋๋ฅผ ์ฐธ๊ณ ํด๋ ๋ฌด๊ดํ๋ค.
-
-### ์ด๊ธฐ ์ค์
-- ํ๋ก๊ทธ๋จ ์์ ์ ์ญ, ๋
ธ์ , ๊ตฌ๊ฐ ์ ๋ณด๋ฅผ ์ด๊ธฐ ์ค์ ํด์ผ ํ๋ค.
-- ๊ฑฐ๋ฆฌ์ ์์ ์๊ฐ์ ์์ ์ ์์ด๋ฉฐ ๋จ์๋ km์ ๋ถ์ ์๋ฏธํ๋ค.
-- ์๋์ ์ฌ์ ๋ฑ๋ก ์ ๋ณด๋ก ๋ฐ๋์ ์ด๊ธฐ ์ค์ ์ ํ๋ค.
-
-```
- 1. ์งํ์ฒ ์ญ์ผ๋ก ๊ต๋์ญ, ๊ฐ๋จ์ญ, ์ญ์ผ์ญ, ๋จ๋ถํฐ๋ฏธ๋์ญ, ์์ฌ์ญ, ์์ฌ์๋ฏผ์์ฒ์ญ, ๋งค๋ด์ญ์ด ๋ฑ๋ก๋์ด ์๋ค.
- 2. ์งํ์ฒ ๋
ธ์ ์ผ๋ก 2ํธ์ , 3ํธ์ , ์ ๋ถ๋น์ ์ด ๋ฑ๋ก๋์ด ์๋ค.
- 3. ๋
ธ์ ์ ์ญ์ด ์๋์ ๊ฐ์ด ๋ฑ๋ก๋์ด ์๋ค.(์ผ์ชฝ ๋์ด ์ํ ์ข
์ )
- - 2ํธ์ : ๊ต๋์ญ - ( 2km / 3๋ถ ) - ๊ฐ๋จ์ญ - ( 2km / 3๋ถ ) - ์ญ์ผ์ญ
- - 3ํธ์ : ๊ต๋์ญ - ( 3km / 2๋ถ ) - ๋จ๋ถํฐ๋ฏธ๋์ญ - ( 6km / 5๋ถ ) - ์์ฌ์ญ - ( 1km / 1๋ถ ) - ๋งค๋ด์ญ
- - ์ ๋ถ๋น์ : ๊ฐ๋จ์ญ - ( 2km / 8๋ถ ) - ์์ฌ์ญ - ( 10km / 3๋ถ ) - ์์ฌ์๋ฏผ์์ฒ์ญ
- ```
-
-### ๊ฒฝ๋ก ์กฐํ ๊ธฐ๋ฅ
-- ์ถ๋ฐ์ญ๊ณผ ๋์ฐฉ์ญ์ ์
๋ ฅ๋ฐ์ ๊ฒฝ๋ก๋ฅผ ์กฐํํ๋ค.
-- ๊ฒฝ๋ก ์กฐํ ์ ์ด ๊ฑฐ๋ฆฌ, ์ด ์์ ์๊ฐ๋ ํจ๊ป ์ถ๋ ฅํ๋ค.
-- ๊ฒฝ๋ก ์กฐํ ๊ธฐ์ค์ `์ต๋จ ๊ฑฐ๋ฆฌ` `์ต์ ์๊ฐ`์ด ์๋ค.
-
-### ์์ธ ์ฒ๋ฆฌ
-- ๊ฒฝ๋ก ์กฐํ ์ ์ถ๋ฐ์ญ๊ณผ ๋์ฐฉ์ญ์ด ๊ฐ์ผ๋ฉด ์๋ฌ๋ฅผ ์ถ๋ ฅํ๋ค.
-- ๊ฒฝ๋ก ์กฐํ ์ ์ถ๋ฐ์ญ๊ณผ ๋์ฐฉ์ญ์ด ์ฐ๊ฒฐ๋์ด ์์ง ์์ผ๋ฉด ์๋ฌ๋ฅผ ์ถ๋ ฅํ๋ค.
-- ๊ทธ ์ธ ์ ์์ ์ผ๋ก ํ๋ก๊ทธ๋จ์ด ์ํ๋์ง ์์ ๊ฒฝ์ฐ ์๋ฌ๋ฅผ ์ถ๋ ฅํ๋ค.
-
-
-
-## โ๐ป ์
์ถ๋ ฅ ์๊ตฌ์ฌํญ
-- `ํ๋ก๊ทธ๋๋ฐ ์คํ ๊ฒฐ๊ณผ ์์`์ ๋์ผํ๊ฒ ์
์ถ๋ ฅ์ ๊ตฌํํ๋ค.
-- ๊ธฐ๋ํ๋ ์ถ๋ ฅ ๊ฒฐ๊ณผ๋ `[INFO]`๋ฅผ ๋ถ์ฌ์ ์ถ๋ ฅํ๋ค. ์ถ๋ ฅ๊ฐ์ ํ์์ ์์์ ๋์ผํ๊ฒ ํ๋ค.
-- ์๋ฌ ๋ฐ์ ์ `[ERROR]`๋ฅผ ๋ถ์ฌ์ ์ถ๋ ฅํ๋ค. ์๋ฌ์ ๋ฌธ๊ตฌ๋ ์์ ๋กญ๊ฒ ์์ฑํ๋ค.
-
-### ๐ป ํ๋ก๊ทธ๋๋ฐ ์คํ ๊ฒฐ๊ณผ ์์
-#### ๊ฒฝ๋ก ์กฐํ
-```
-## ๋ฉ์ธ ํ๋ฉด
-1. ๊ฒฝ๋ก ์กฐํ
-Q. ์ข
๋ฃ
-
-## ์ํ๋ ๊ธฐ๋ฅ์ ์ ํํ์ธ์.
-1
-
-## ๊ฒฝ๋ก ๊ธฐ์ค
-1. ์ต๋จ ๊ฑฐ๋ฆฌ
-2. ์ต์ ์๊ฐ
-B. ๋์๊ฐ๊ธฐ
-
-## ์ํ๋ ๊ธฐ๋ฅ์ ์ ํํ์ธ์.
-1
-
-## ์ถ๋ฐ์ญ์ ์
๋ ฅํ์ธ์.
-๊ต๋์ญ
-
-## ๋์ฐฉ์ญ์ ์
๋ ฅํ์ธ์.
-์์ฌ์ญ
-
-## ์กฐํ ๊ฒฐ๊ณผ
-[INFO] ---
-[INFO] ์ด ๊ฑฐ๋ฆฌ: 6km
-[INFO] ์ด ์์ ์๊ฐ: 14๋ถ
-[INFO] ---
-[INFO] ๊ต๋์ญ
-[INFO] ๊ฐ๋จ์ญ
-[INFO] ์์ฌ์ญ
-
-## ๋ฉ์ธ ํ๋ฉด
-1. ๊ฒฝ๋ก ์กฐํ
-Q. ์ข
๋ฃ
-
-...
-```
-
-#### ์๋ฌ ์ถ๋ ฅ ์์
-
-```
-## ๋ฉ์ธ ํ๋ฉด
-1. ๊ฒฝ๋ก ์กฐํ
-Q. ์ข
๋ฃ
-
-## ์ํ๋ ๊ธฐ๋ฅ์ ์ ํํ์ธ์.
-1
-
-## ๊ฒฝ๋ก ๊ธฐ์ค
-1. ์ต๋จ ๊ฑฐ๋ฆฌ
-2. ์ต์ ์๊ฐ
-B. ๋์๊ฐ๊ธฐ
-
-## ์ํ๋ ๊ธฐ๋ฅ์ ์ ํํ์ธ์.
-1
-
-## ์ถ๋ฐ์ญ์ ์
๋ ฅํ์ธ์.
-๊ฐ๋จ์ญ
-
-## ๋์ฐฉ์ญ์ ์
๋ ฅํ์ธ์.
-๊ฐ๋จ์ญ
-
-[ERROR] ์ถ๋ฐ์ญ๊ณผ ๋์ฐฉ์ญ์ด ๋์ผํฉ๋๋ค.
-
-## ๊ฒฝ๋ก ๊ธฐ์ค
-1. ์ต๋จ ๊ฑฐ๋ฆฌ
-2. ์ต์ ์๊ฐ
-B. ๋์๊ฐ๊ธฐ
-
-## ์ํ๋ ๊ธฐ๋ฅ์ ์ ํํ์ธ์.
-
-...
-
-```
-
-
-
-## ๐ฑ ํ๋ก๊ทธ๋๋ฐ ์๊ตฌ์ฌํญ
-- ์๋ฐ ์ฝ๋ ์ปจ๋ฒค์
์ ์งํค๋ฉด์ ํ๋ก๊ทธ๋๋ฐํ๋ค.
- - ๊ธฐ๋ณธ์ ์ผ๋ก [Google Java Style Guide](https://google.github.io/styleguide/javaguide.html)์ ์์น์ผ๋ก ํ๋ค.
- - ๋จ, ๋ค์ฌ์ฐ๊ธฐ๋ '2 spaces'๊ฐ ์๋ '4 spaces'๋ก ํ๋ค.
-- indent(์ธ๋ดํธ, ๋ค์ฌ์ฐ๊ธฐ) depth๋ฅผ 3์ด ๋์ง ์๋๋ก ๊ตฌํํ๋ค. 2๊น์ง๋ง ํ์ฉํ๋ค.
- - ์๋ฅผ ๋ค์ด while๋ฌธ ์์ if๋ฌธ์ด ์์ผ๋ฉด ๋ค์ฌ์ฐ๊ธฐ๋ 2์ด๋ค.
- - ํํธ: indent(์ธ๋ดํธ, ๋ค์ฌ์ฐ๊ธฐ) depth๋ฅผ ์ค์ด๋ ์ข์ ๋ฐฉ๋ฒ์ ํจ์(๋๋ ๋ฉ์๋)๋ฅผ ๋ถ๋ฆฌํ๋ฉด ๋๋ค.
-- 3ํญ ์ฐ์ฐ์๋ฅผ ์ฐ์ง ์๋๋ค.
-- ํจ์(๋๋ ๋ฉ์๋)์ ๊ธธ์ด๊ฐ 15๋ผ์ธ์ ๋์ด๊ฐ์ง ์๋๋ก ๊ตฌํํ๋ค.
- - ํจ์(๋๋ ๋ฉ์๋)๊ฐ ํ ๊ฐ์ง ์ผ๋ง ์ ํ๋๋ก ๊ตฌํํ๋ค.
-- else ์์ฝ์ด๋ฅผ ์ฐ์ง ์๋๋ค.
- - ํํธ: if ์กฐ๊ฑด์ ์์ ๊ฐ์ returnํ๋ ๋ฐฉ์์ผ๋ก ๊ตฌํํ๋ฉด else๋ฅผ ์ฌ์ฉํ์ง ์์๋ ๋๋ค.
- - else๋ฅผ ์ฐ์ง ๋ง๋ผ๊ณ ํ๋ switch/case๋ก ๊ตฌํํ๋ ๊ฒฝ์ฐ๊ฐ ์๋๋ฐ switch/case๋ ํ์ฉํ์ง ์๋๋ค.
-- ํ๋ก๊ทธ๋๋ฐ ์๊ตฌ์ฌํญ์์ ๋ณ๋๋ก ๋ณ๊ฒฝ ๋ถ๊ฐ ์๋ด๊ฐ ์๋ ๊ฒฝ์ฐ ํ์ผ ์์ ๊ณผ ํจํค์ง ์ด๋์ ์์ ๋กญ๊ฒ ํ ์ ์๋ค.
-- ์์ธ ์ํฉ ์ ์๋ฌ ๋ฌธ๊ตฌ๋ฅผ ์ถ๋ ฅํด์ผ ํ๋ค. ๋จ, ์๋ฌ ๋ฌธ๊ตฌ๋ `[ERROR]` ๋ก ์์ํด์ผ ํ๋ค.
-
-### ํ๋ก๊ทธ๋๋ฐ ์๊ตฌ์ฌํญ - Application
-- Application ํด๋์ค๋ฅผ ํ์ฉํด ๊ตฌํํด์ผ ํ๋ค.
-- Application์ ํจํค์ง ๊ตฌ์กฐ๋ ๋ณ๊ฒฝํ์ง ์๋๋ค.
-- Application ํด๋์ค์ ์๋ Scanner๋ฅผ ์ฌ์ฉํ๊ณ ๋ณ๋์ Scanner ๊ฐ์ฒด๋ฅผ ๋ง๋ค์ง ์๋๋ค.
-```java
-public class Application {
- public static void main(String[] args) {
- final Scanner scanner = new Scanner(System.in);
- ...
- }
-}
-```
-
-### ํ๋ก๊ทธ๋๋ฐ ์๊ตฌ์ฌํญ - Station, Line
-- Station, Line ํด๋์ค๋ฅผ ํ์ฉํ์ฌ ์งํ์ฒ ์ญ๊ณผ ๋
ธ์ ์ ๊ตฌํํด์ผ ํ๋ค.
-- ์ ๊ณตํ๋ ๊ฐ ํด๋์ค์ ๊ธฐ๋ณธ ์์ฑ์๋ฅผ ์ถ๊ฐํ ์ ์๋ค.
-- ํ๋(์ธ์คํด์ค ๋ณ์)์ธ name์ ์ ๊ทผ ์ ์ด์ private์ ๋ณ๊ฒฝํ ์ ์๋ค.
-- ๊ฐ๋ฅํ๋ฉด setter ๋ฉ์๋(ex. setXXX)๋ฅผ ์ถ๊ฐํ์ง ์๊ณ ๊ตฌํํ๋ค.
-
-```java
-public class Station {
- private String name;
-
- public Station(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- // ์ถ๊ฐ ๊ธฐ๋ฅ ๊ตฌํ
-}
-
-```
-
-### ํ๋ก๊ทธ๋๋ฐ ์๊ตฌ์ฌํญ - StationRepository, LineRepository
-- Station๊ณผ Line์ ์ํ๋ฅผ ์ ์ฅํ ์ ์๋ StationRepository, LineRepository๋ฅผ ์ ๊ณตํ๋ค.
-- ํ์ ์ StationRepository, LineRepository ์ด ์ธ ์ถ๊ฐ๋ก Repository๋ฅผ ๋ง๋ค ์ ์๋ค.
-- ์ถ๊ฐ๋ก ์์ฑ๋๋ ๊ฐ์ฒด์ ๋ํด์ XXXRepository ๋ค์ด๋ฐ์ผ๋ก ์ ์ฅ ํด๋์ค๋ฅผ ์ถ๊ฐํ๋ค.
-- ๊ฐ์ฒด๋ค์ ์ํ๋ฅผ ๊ด๋ฆฌํ๊ธฐ ์ํด์ XXXRepository ํด๋์ค๋ฅผ ํ์ฉํด ์ ์ฅ ๋ก์ง์ ๊ตฌํํด์ผ ํ๋ค.
-- ์์ฑ๋ ๋ฉ์๋๋ ์์ ํ ์ ์๊ณ , ํ์์ ๋ฐ๋ผ ๋ฉ์๋๋ฅผ ์์ ๋กญ๊ฒ ์ถ๊ฐํ ์ ์๋ค.
-
-```java
-public class StationRepository {
- private static final List stations = new ArrayList<>();
-
- public static List stations() {
- return Collections.unmodifiableList(stations);
- }
-
- public static void addStation(Station station) {
- stations.add(station);
- }
-
- public static boolean deleteStation(String name) {
- return stations.removeIf(station -> Objects.equals(station.getName(), name));
- }
-
- public static void deleteAll() {
- stations.clear();
- }
-}
-```
-
-
-
-## โ๏ธํํธ
-### ์ต๋จ ๊ฒฝ๋ก ๋ผ์ด๋ธ๋ฌ๋ฆฌ
-- jgrapht ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ํ์ฉํ๋ฉด ๊ฐํธํ๊ฒ ์ต๋จ๊ฑฐ๋ฆฌ๋ฅผ ์กฐํํ ์ ์์
-- Dijkstra ์๊ณ ๋ฆฌ์ฆ์ ๋ฐ๋์ ์ดํดํ ํ์๋ ์๊ณ ๋ฏธ์
์ ์ ์ฉํ ์ ๋๋ก๋ง ์ดํดํ๋ฉด ๋จ
-- JGraphtTest ํด๋์ค์ ํ
์คํธ๋ฅผ ํ์ฉํ์ฌ ๋ฏธ์
์ ํ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๊ธฐ๋ฅ์ ํ์ตํ ์ ์์
-- ์ ์ (vertex)๊ณผ ๊ฐ์ (edge), ๊ทธ๋ฆฌ๊ณ ๊ฐ์ค์น ๊ฐ๋
์ ์ด์ฉ
- - ์ ์ : ์งํ์ฒ ์ญ
- - ๊ฐ์ : ์งํ์ฒ ์ญ ์ฐ๊ฒฐ์ ๋ณด
- - ๊ฐ์ค์น: ๊ฑฐ๋ฆฌ or ์์ ์๊ฐ
-- ์ต๋จ ๊ฑฐ๋ฆฌ ๊ธฐ์ค ์กฐํ ์ ๊ฐ์ค์น๋ฅผ ๊ฑฐ๋ฆฌ๋ก ์ค์
-
-```java
-@Test
-public void getDijkstraShortestPath() {
- WeightedMultigraph graph
- = new WeightedMultigraph(DefaultWeightedEdge.class);
- graph.addVertex("v1");
- graph.addVertex("v2");
- graph.addVertex("v3");
- graph.setEdgeWeight(graph.addEdge("v1", "v2"), 2);
- graph.setEdgeWeight(graph.addEdge("v2", "v3"), 2);
- graph.setEdgeWeight(graph.addEdge("v1", "v3"), 100);
-
- DijkstraShortestPath dijkstraShortestPath = new DijkstraShortestPath(graph);
- List shortestPath = dijkstraShortestPath.getPath("v3", "v1").getVertexList();
-
- assertThat(shortestPath.size()).isEqualTo(3);
-}
-```
-
-#### ํ
์คํธ ์ค๋ช
-
-
-
-- ์ญ ์ฌ์ด์ ๊ฑฐ๋ฆฌ๋ฅผ ๊ณ ๋ คํ์ง ์๋ ๊ฒฝ์ฐ V1->V3 ๊ฒฝ๋ก๊ฐ ์ต๋จ ๊ฒฝ๋ก
-- ์ญ ์ฌ์ด์ ๊ฑฐ๋ฆฌ๋ฅผ ๊ณ ๋ คํ ๊ฒฝ์ฐ V1->V3 ๊ฒฝ๋ก์ ๊ฑฐ๋ฆฌ๋ 100km, V1->V2->V3 ๊ฒฝ๋ก์ ๊ฑฐ๋ฆฌ๋ 4km์ด๋ฏ๋ก ์ต๋จ ๊ฒฝ๋ก๋ V1->V2->V3
-
-
-
-## ๐ ์งํ ์๊ตฌ์ฌํญ
-- ๋ฏธ์
์ [java-subway-path-precourse ์ ์ฅ์](https://github.com/woowacourse/java-subway-path-precourse) ๋ฅผ fork/cloneํด ์์ํ๋ค.
-- ๊ธฐ๋ฅ์ ๊ตฌํํ๊ธฐ ์ ์ java-subway-path-precourse/docs/README.md ํ์ผ์ ๊ตฌํํ ๊ธฐ๋ฅ ๋ชฉ๋ก์ ์ ๋ฆฌํด ์ถ๊ฐํ๋ค.
-- git์ commit ๋จ์๋ ์ ๋จ๊ณ์์ README.md ํ์ผ์ ์ ๋ฆฌํ ๊ธฐ๋ฅ ๋ชฉ๋ก ๋จ์๋ก ์ถ๊ฐํ๋ค.
- - [AngularJS Commit Message Conventions](https://gist.github.com/stephenparish/9941e89d80e2bc58a153) ์ฐธ๊ณ ํด commit log๋ฅผ ๋จ๊ธด๋ค.
-- [ํ๋ฆฌ์ฝ์ค ๊ณผ์ ์ ์ถ ๋ฌธ์](https://github.com/woowacourse/woowacourse-docs/tree/master/precourse) ์ ์ฐจ๋ฅผ ๋ฐ๋ผ ๋ฏธ์
์ ์ ์ถํ๋ค.
- - [ํ๋ฆฌ์ฝ์ค ๊ณผ์ FAQ](https://github.com/woowacourse/woowacourse-docs/tree/master/precourse/faq) ๋ฌธ์๋ฅผ ์ฐธ๊ณ ํ์ฌ ์งํํ ์ ์๋ค.
-
-
-## ๐ License
-
-This project is [MIT](https://github.com/woowacourse/java-subway-path-precourse/blob/master/LICENSE.md) licensed.
+- ์ญ, ๋
ธ์ , ๊ตฌ๊ฐ ์ ๋ณด ์ด๊ธฐํ(๋จ์ km, ๋ถ)
+- ๋ฉ์ธ ํ๋ฉด์์ ๊ธฐ๋ฅ ์ ํ
+- ์ถ๋ฐ์ญ, ๋์ฐฉ์ญ ์
๋ ฅ๋ฐ๊ธฐ
+- ๊ฒฝ๋ก ์กฐํ ์ ๊ฑฐ๋ฆฌ, ์๊ฐ ๊ธฐ์ค
+- ์ด ๊ฑฐ๋ฆฌ, ์ด ์์์๊ฐ, ์ง๋์จ ๊ตฌ๊ฐ ์ถ๋ ฅ
+- ์์ธ ์ฒ๋ฆฌ
+- ๋ค์ต์คํธ๋ผ๋ฅผ ํ์ฉํ์ฌ ๊ฒฝ๋ก ๊ตฌํ๊ธฐ
\ No newline at end of file
From 52dee6fda0ee1ff0a7b378c62c9be7ab28715dc0 Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 13:25:56 +0900
Subject: [PATCH 02/25] =?UTF-8?q?docs:=20README.md=20=EA=B5=AC=ED=98=84?=
=?UTF-8?q?=ED=95=A0=20=EA=B8=B0=EB=8A=A5=20=EB=AA=A9=EB=A1=9D=20=EC=B6=94?=
=?UTF-8?q?=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 450a9183e..a960bc7a3 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
-## ๐ ๊ธฐ๋ฅ ์๊ตฌ์ฌํญ
+## ๊ตฌํํ ๊ธฐ๋ฅ ๋ชฉ๋ก
- ์ญ, ๋
ธ์ , ๊ตฌ๊ฐ ์ ๋ณด ์ด๊ธฐํ(๋จ์ km, ๋ถ)
- ๋ฉ์ธ ํ๋ฉด์์ ๊ธฐ๋ฅ ์ ํ
From f8732e8a6b4770ec883ea0133f904da79f5f3e70 Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 13:30:23 +0900
Subject: [PATCH 03/25] =?UTF-8?q?feat:=20=EC=9E=85=EB=A0=A5=20=ED=95=98?=
=?UTF-8?q?=EB=8A=94=20User=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=83=9D?=
=?UTF-8?q?=EC=84=B1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/User.java | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 src/main/java/subway/User.java
diff --git a/src/main/java/subway/User.java b/src/main/java/subway/User.java
new file mode 100644
index 000000000..7de1c3a59
--- /dev/null
+++ b/src/main/java/subway/User.java
@@ -0,0 +1,16 @@
+package subway;
+
+import java.util.Scanner;
+
+public class User {
+
+ private final Scanner scanner;
+
+ public User(Scanner scanner) {
+ this.scanner = scanner;
+ }
+
+ public String getInput() {
+ return scanner.nextLine();
+ }
+}
From dcc6b8f7606e948810f161f8aefee034d56d6d51 Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 13:40:21 +0900
Subject: [PATCH 04/25] =?UTF-8?q?feat:=20=ED=99=94=EB=A9=B4=20=EC=B6=9C?=
=?UTF-8?q?=EB=A0=A5=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/PrintScreen.java | 33 +++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
create mode 100644 src/main/java/subway/PrintScreen.java
diff --git a/src/main/java/subway/PrintScreen.java b/src/main/java/subway/PrintScreen.java
new file mode 100644
index 000000000..71735b278
--- /dev/null
+++ b/src/main/java/subway/PrintScreen.java
@@ -0,0 +1,33 @@
+package subway;
+
+public class PrintScreen {
+
+ public static void printMain() {
+ System.out.println("## ๋ฉ์ธ ํ๋ฉด");
+ System.out.println("1. ๊ฒฝ๋ก ์กฐํ");
+ System.out.println("Q. ์ข
๋ฃ");
+
+ selectFunction();
+ }
+
+ public static void selectFunction() {
+ System.out.println("## ์ํ๋ ๊ธฐ๋ฅ์ ์ ํํ์ธ์.");
+ }
+
+ public static void selectStandard() {
+ System.out.println("## ๊ฒฝ๋ก ๊ธฐ์ค");
+ System.out.println("1. ์ต๋จ ๊ฑฐ๋ฆฌ");
+ System.out.println("2. ์ต์ ์๊ฐ");
+ System.out.println("B. ๋์๊ฐ๊ธฐ");
+
+ selectFunction();
+ }
+
+ public static void printInputStartStation() {
+ System.out.println("## ์ถ๋ฐ์ญ์ ์
๋ ฅํ์ธ์.");
+ }
+
+ public static void printInputArriveStation() {
+ System.out.println("## ๋์ฐฉ์ญ์ ์
๋ ฅํ์ธ์.");
+ }
+}
From c3d9d0dbd8a974bc01a1450a79d232d0ed699a5c Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 13:42:12 +0900
Subject: [PATCH 05/25] =?UTF-8?q?feat:=20Constants=20=ED=81=B4=EB=9E=98?=
=?UTF-8?q?=EC=8A=A4=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/Constants.java | 8 ++++++++
1 file changed, 8 insertions(+)
create mode 100644 src/main/java/subway/Constants.java
diff --git a/src/main/java/subway/Constants.java b/src/main/java/subway/Constants.java
new file mode 100644
index 000000000..c958b67ef
--- /dev/null
+++ b/src/main/java/subway/Constants.java
@@ -0,0 +1,8 @@
+package subway;
+
+public class Constants {
+ public static final String FUNCTION_ONE = "1";
+ public static final String FUNCTION_TWO = "2";
+ public static final String FUNCTION_Q = "Q";
+ public static final String FUNCTION_B = "B";
+}
From e57bbce04b107604a82374d6328ee26c00210b3b Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 14:24:55 +0900
Subject: [PATCH 06/25] =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EB=A1=9C=EC=A7=81?=
=?UTF-8?q?=20=EA=B5=AC=ED=98=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/SubwayManagement.java | 53 ++++++++++++++++++++++
1 file changed, 53 insertions(+)
create mode 100644 src/main/java/subway/SubwayManagement.java
diff --git a/src/main/java/subway/SubwayManagement.java b/src/main/java/subway/SubwayManagement.java
new file mode 100644
index 000000000..d340817ce
--- /dev/null
+++ b/src/main/java/subway/SubwayManagement.java
@@ -0,0 +1,53 @@
+package subway;
+
+public class SubwayManagement {
+
+ private User user;
+
+ public SubwayManagement(User user) {
+ this.user = user;
+ }
+
+ public void start() {
+ while (true) {
+ PrintScreen.printMain();
+ String select = user.getInput();
+ try {
+ checkMainSelect(select);
+ } catch (IllegalArgumentException e) {
+ System.out.println(e.getMessage());
+ }
+ if (select.equals(Constants.FUNCTION_ONE)) {
+ findPathFunction();
+ }
+ if (select.equals(Constants.FUNCTION_Q)) {
+ break;
+ }
+ }
+ }
+
+ private void checkMainSelect(String select) {
+ if (!select.equals(Constants.FUNCTION_Q) && !select.equals(Constants.FUNCTION_ONE)) {
+ throw new IllegalArgumentException("[ERROR] ์ ํํ ์ ์๋ ๊ธฐ๋ฅ์
๋๋ค.\n");
+ }
+ }
+
+ private void findPathFunction() {
+ PrintScreen.selectStandard();
+ String select = user.getInput();
+ try {
+ checkFindPathSelect(select);
+ } catch (IllegalArgumentException e) {
+ System.out.println(e.getMessage());
+ }
+ if (select.equals(Constants.FUNCTION_ONE) || select.equals(Constants.FUNCTION_TWO)) {
+ System.out.println(select);
+ }
+ }
+
+ private void checkFindPathSelect(String select) {
+ if(!select.equals(Constants.FUNCTION_ONE) && !select.equals(Constants.FUNCTION_TWO) && !select.equals(Constants.FUNCTION_B)){
+ throw new IllegalArgumentException("[ERROR] ์ ํํ ์ ์๋ ๊ธฐ๋ฅ์
๋๋ค.\n");
+ }
+ }
+}
From b8fc1f93c71be6e9c5345bcd17f5a7aca132cb54 Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 15:32:25 +0900
Subject: [PATCH 07/25] =?UTF-8?q?feat:=20=ED=95=B4=EB=8B=B9=20=EC=97=AD?=
=?UTF-8?q?=EA=B3=BC=20=EC=97=B0=EA=B2=B0=EB=90=98=EC=96=B4=20=EA=B1=B0?=
=?UTF-8?q?=EB=A6=AC=EC=99=80=20=EC=8B=9C=EA=B0=84=EC=9D=84=20=EC=A0=80?=
=?UTF-8?q?=EC=9E=A5=ED=95=98=EB=8A=94=20=ED=81=B4=EB=9E=98=EC=8A=A4=20?=
=?UTF-8?q?=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/domain/NodeData.java | 13 +++++++++++++
1 file changed, 13 insertions(+)
create mode 100644 src/main/java/subway/domain/NodeData.java
diff --git a/src/main/java/subway/domain/NodeData.java b/src/main/java/subway/domain/NodeData.java
new file mode 100644
index 000000000..23abd301d
--- /dev/null
+++ b/src/main/java/subway/domain/NodeData.java
@@ -0,0 +1,13 @@
+package subway.domain;
+
+public class NodeData {
+ private Station nextStation;
+ private int timeCost;
+ private int distanceCost;
+
+ public NodeData(Station nextStation, int timeCost, int distanceCost){
+ this.nextStation = nextStation;
+ this.timeCost = timeCost;
+ this.distanceCost = distanceCost;
+ }
+}
From acbe5dffefec3546b73f92afe3d983a261aeac97 Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 15:32:53 +0900
Subject: [PATCH 08/25] =?UTF-8?q?feat:=20=EB=85=B8=EC=84=A0=EC=9D=98=20?=
=?UTF-8?q?=EA=B5=AC=EA=B0=84=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/domain/Line.java | 7 +++++++
src/main/java/subway/domain/LineRepository.java | 4 ++++
2 files changed, 11 insertions(+)
diff --git a/src/main/java/subway/domain/Line.java b/src/main/java/subway/domain/Line.java
index f4d738d5a..3c7427f86 100644
--- a/src/main/java/subway/domain/Line.java
+++ b/src/main/java/subway/domain/Line.java
@@ -1,7 +1,11 @@
package subway.domain;
+import java.util.ArrayList;
+import java.util.List;
+
public class Line {
private String name;
+ private List sections = new ArrayList<>();
public Line(String name) {
this.name = name;
@@ -12,4 +16,7 @@ public String getName() {
}
// ์ถ๊ฐ ๊ธฐ๋ฅ ๊ตฌํ
+ public void addStationInSection(String name) {
+ sections.add(new Station(name));
+ }
}
diff --git a/src/main/java/subway/domain/LineRepository.java b/src/main/java/subway/domain/LineRepository.java
index 2c4a723c9..d41305f8b 100644
--- a/src/main/java/subway/domain/LineRepository.java
+++ b/src/main/java/subway/domain/LineRepository.java
@@ -23,4 +23,8 @@ public static boolean deleteLineByName(String name) {
public static void deleteAll() {
lines.clear();
}
+
+ public static void addSection(int idx, String stationName) {
+ lines.get(idx).addStationInSection(stationName);
+ }
}
From a556fd015aadc4250d06779fbc6c8a572c54ad72 Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 15:33:53 +0900
Subject: [PATCH 09/25] =?UTF-8?q?feat:=20=EC=97=AD=EA=B3=BC=20=EC=97=AD=20?=
=?UTF-8?q?=EC=82=AC=EC=9D=B4=EC=9D=98=20=EA=B1=B0=EB=A6=AC=EC=99=80=20?=
=?UTF-8?q?=EC=8B=9C=EA=B0=84=EC=9D=84=20=EC=84=B8=ED=8C=85=ED=95=98?=
=?UTF-8?q?=EB=8A=94=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/domain/Station.java | 12 ++++++++++++
src/main/java/subway/domain/StationRepository.java | 11 +++++++++++
2 files changed, 23 insertions(+)
diff --git a/src/main/java/subway/domain/Station.java b/src/main/java/subway/domain/Station.java
index bdb142590..d5354dbcd 100644
--- a/src/main/java/subway/domain/Station.java
+++ b/src/main/java/subway/domain/Station.java
@@ -1,7 +1,12 @@
package subway.domain;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
public class Station {
private String name;
+ private List nodeData = new ArrayList<>();
public Station(String name) {
this.name = name;
@@ -12,4 +17,11 @@ public String getName() {
}
// ์ถ๊ฐ ๊ธฐ๋ฅ ๊ตฌํ
+ public void addNodeData(String nextStation, int timeCost, int distanceCost){
+ nodeData.add(new NodeData(new Station(nextStation), timeCost, distanceCost));
+ }
+
+ public List getNodeData(){
+ return Collections.unmodifiableList(nodeData);
+ }
}
diff --git a/src/main/java/subway/domain/StationRepository.java b/src/main/java/subway/domain/StationRepository.java
index 8ed9d103f..3cb363b92 100644
--- a/src/main/java/subway/domain/StationRepository.java
+++ b/src/main/java/subway/domain/StationRepository.java
@@ -23,4 +23,15 @@ public static boolean deleteStation(String name) {
public static void deleteAll() {
stations.clear();
}
+
+ public static void setCost(String prevStationName, String nextStationName, int timeCost, int distanceCost) {
+ for (int i = 0; i < stations.size(); i++) {
+ if (stations.get(i).getName().equals(prevStationName)) {
+ stations().get(i).addNodeData(nextStationName, timeCost, distanceCost);
+ }
+ if (stations.get(i).getName().equals(nextStationName)) {
+ stations.get(i).addNodeData(prevStationName, timeCost, distanceCost);
+ }
+ }
+ }
}
From 19704fc3151cee4f428c9b47e31eaa893d252b72 Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 15:34:06 +0900
Subject: [PATCH 10/25] =?UTF-8?q?feat:=20=EC=B4=88=EA=B8=B0=20=EC=84=A4?=
=?UTF-8?q?=EC=A0=95=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/InitSetting.java | 56 +++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 src/main/java/subway/InitSetting.java
diff --git a/src/main/java/subway/InitSetting.java b/src/main/java/subway/InitSetting.java
new file mode 100644
index 000000000..88bf4cc43
--- /dev/null
+++ b/src/main/java/subway/InitSetting.java
@@ -0,0 +1,56 @@
+package subway;
+
+import subway.domain.Line;
+import subway.domain.LineRepository;
+import subway.domain.Station;
+import subway.domain.StationRepository;
+
+public class InitSetting {
+
+ private static String[] initStation = {"๊ต๋์ญ", "๊ฐ๋จ์ญ", "์ญ์ผ์ญ", "๋จ๋ถํฐ๋ฏธ๋์ญ", "์์ฌ์ญ", "์์ฌ์๋ฏผ์์ฒ์ญ", "๋งค๋ด์ญ"};
+ private static String[] initLine = {"2ํธ์ ", "3ํธ์ ", "์ ๋ถ๋น์ "};
+ private static String[][] initSection = {{"๊ต๋์ญ", "๊ฐ๋จ์ญ", "์ญ์ผ์ญ"}, {"๊ต๋์ญ", "๋จ๋ถํฐ๋ฏธ๋์ญ", "์์ฌ์ญ", "๋งค๋ด์ญ"}, {"๊ฐ๋จ์ญ", "์์ฌ์ญ", "์์ฌ์๋ฏผ์์ฒ์ญ"}};
+ // "km, ๋ถ"
+ private static String[][] initCost = {{"2,3", "2,3"}, {"3,2", "6,5", "1,1"}, {"2,8", "10,3"}};
+
+
+ public static void initSetting() {
+ setInitStation();
+ setInitLine();
+ setInitSection();
+ setInitCost();
+ }
+
+ private static void setInitStation() {
+ for (String name : initStation) {
+ StationRepository.addStation(new Station(name));
+ }
+ }
+
+ private static void setInitLine() {
+ for (String name : initLine) {
+ LineRepository.addLine(new Line(name));
+ }
+ }
+
+ private static void setInitSection() {
+ for (int i = 0; i < initSection.length; i++) {
+ for (String name : initSection[i]) {
+ LineRepository.addSection(i, name);
+ }
+ }
+ }
+
+ private static void setInitCost() {
+ for (int i = 0; i < initCost.length; i++) {
+ for (int j = 0; j < initCost[i].length; j++) {
+ String[] cost = initCost[i][j].split(",");
+ int distanceCost = Integer.parseInt(cost[0]);
+ int timeCost = Integer.parseInt(cost[1]);
+ String curStation = initSection[i][j];
+ String nextStation = initSection[i][j + 1];
+ StationRepository.setCost(curStation, nextStation, timeCost, distanceCost);
+ }
+ }
+ }
+}
From 3a66fd00b1fa015d505051ca94cfbc21af42991d Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 15:43:22 +0900
Subject: [PATCH 11/25] =?UTF-8?q?docs:=20README.md=20=EC=98=88=EC=99=B8=20?=
=?UTF-8?q?=EC=82=AC=ED=95=AD=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index a960bc7a3..a98d068c2 100644
--- a/README.md
+++ b/README.md
@@ -6,9 +6,11 @@
## ๊ตฌํํ ๊ธฐ๋ฅ ๋ชฉ๋ก
- ์ญ, ๋
ธ์ , ๊ตฌ๊ฐ ์ ๋ณด ์ด๊ธฐํ(๋จ์ km, ๋ถ)
+ - ์ฌ์ฉ์ ์
๋ ฅ ๋ฐ๋ ๋ถ๋ถ์ด ์๋๊ธฐ ๋๋ฌธ์ ์์ธ์ฒ๋ฆฌ๋ฅผ ํด์ฃผ์ง ์์๋ค.
- ๋ฉ์ธ ํ๋ฉด์์ ๊ธฐ๋ฅ ์ ํ
+ - ์์ธ ์ฒ๋ฆฌ : ์ ํ ๊ฐ๋ฅํ์ง ์์ ๊ธฐ๋ฅ ๋ฒํธ ์
๋ ฅ
- ์ถ๋ฐ์ญ, ๋์ฐฉ์ญ ์
๋ ฅ๋ฐ๊ธฐ
+ - ์ญ ๋ชฉ๋ก์ ์กด์ฌํ์ง ์๋ ์
๋ ฅ
- ๊ฒฝ๋ก ์กฐํ ์ ๊ฑฐ๋ฆฌ, ์๊ฐ ๊ธฐ์ค
- ์ด ๊ฑฐ๋ฆฌ, ์ด ์์์๊ฐ, ์ง๋์จ ๊ตฌ๊ฐ ์ถ๋ ฅ
-- ์์ธ ์ฒ๋ฆฌ
- ๋ค์ต์คํธ๋ผ๋ฅผ ํ์ฉํ์ฌ ๊ฒฝ๋ก ๊ตฌํ๊ธฐ
\ No newline at end of file
From fcf65df0e50ff327d504149338045ef8b0c4bd9b Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 15:51:30 +0900
Subject: [PATCH 12/25] =?UTF-8?q?feat:=20=EC=B4=88=EA=B8=B0=20=EC=84=A4?=
=?UTF-8?q?=EC=A0=95=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94=EA=B0=80,?=
=?UTF-8?q?=20=EA=B2=BD=EB=A1=9C=20=EC=A1=B0=ED=9A=8C=20=EB=A1=9C=EC=A7=81?=
=?UTF-8?q?=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/SubwayManagement.java | 30 ++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/src/main/java/subway/SubwayManagement.java b/src/main/java/subway/SubwayManagement.java
index d340817ce..acd2a913e 100644
--- a/src/main/java/subway/SubwayManagement.java
+++ b/src/main/java/subway/SubwayManagement.java
@@ -1,5 +1,7 @@
package subway;
+import subway.domain.StationRepository;
+
public class SubwayManagement {
private User user;
@@ -9,6 +11,9 @@ public SubwayManagement(User user) {
}
public void start() {
+
+ InitSetting.initSetting();
+
while (true) {
PrintScreen.printMain();
String select = user.getInput();
@@ -41,13 +46,34 @@ private void findPathFunction() {
System.out.println(e.getMessage());
}
if (select.equals(Constants.FUNCTION_ONE) || select.equals(Constants.FUNCTION_TWO)) {
- System.out.println(select);
+ selectFindPathFunction(select);
}
}
private void checkFindPathSelect(String select) {
- if(!select.equals(Constants.FUNCTION_ONE) && !select.equals(Constants.FUNCTION_TWO) && !select.equals(Constants.FUNCTION_B)){
+ if (!select.equals(Constants.FUNCTION_ONE) && !select.equals(Constants.FUNCTION_TWO) && !select.equals(Constants.FUNCTION_B)) {
throw new IllegalArgumentException("[ERROR] ์ ํํ ์ ์๋ ๊ธฐ๋ฅ์
๋๋ค.\n");
}
}
+
+ private void selectFindPathFunction(String select) {
+ PrintScreen.printInputStartStation();
+ String startStation = user.getInput();
+ PrintScreen.printInputArriveStation();
+ String arriveStation = user.getInput();
+
+ try {
+ checkContainStation(startStation, arriveStation);
+ } catch (IllegalArgumentException e) {
+ System.out.println(e.getMessage());
+ return;
+ }
+ FindPath.start(select, startStation, arriveStation);
+ }
+
+ private void checkContainStation(String startStation, String arriveStation) {
+ if (!StationRepository.isContain(startStation) || !StationRepository.isContain(arriveStation)) {
+ throw new IllegalArgumentException("[ERROR] ์กด์ฌํ์ง ์๋ ์ญ์
๋๋ค.\n");
+ }
+ }
}
From 9156d77be9ec19740bdf4a32f6a85f35cc956f8e Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 16:32:16 +0900
Subject: [PATCH 13/25] =?UTF-8?q?feat:=20=EB=8B=A4=EC=9D=B5=EC=8A=A4?=
=?UTF-8?q?=ED=8A=B8=EB=9D=BC=20=EC=B4=88=EA=B8=B0=20=EC=84=B8=ED=8C=85=20?=
=?UTF-8?q?=EC=84=A4=EC=A0=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/FindPath.java | 83 ++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
create mode 100644 src/main/java/subway/FindPath.java
diff --git a/src/main/java/subway/FindPath.java b/src/main/java/subway/FindPath.java
new file mode 100644
index 000000000..4ccfa5084
--- /dev/null
+++ b/src/main/java/subway/FindPath.java
@@ -0,0 +1,83 @@
+package subway;
+
+import subway.domain.NodeData;
+import subway.domain.Station;
+import subway.domain.StationRepository;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class FindPath {
+
+ private static ArrayList> subwayList;
+ private static int dist[];
+ private static int stationSize;
+
+ public static void start(String select, String startStation, String arriveStation) {
+ setBeforeDijkstra(select);
+ }
+
+ private static void setBeforeDijkstra(String select) {
+ subwayList = new ArrayList>();
+ stationSize = StationRepository.getSize();
+ setSubwayList(select);
+ dist = new int[stationSize];
+
+ Arrays.fill(dist, Integer.MAX_VALUE);
+ }
+
+ private static void setSubwayList(String select) {
+ for (int i = 0; i < stationSize; i++) {
+ subwayList.add(new ArrayList());
+ }
+
+ for (int i = 0; i < stationSize; i++) {
+ Station station = StationRepository.stations().get(i);
+ for (NodeData nodeData : station.getNodeData()) {
+ int cost = selectDistanceOrTime(select, nodeData);
+ subwayList.get(i).add(new Pair(findNumberByName(nodeData.getBeforeStation()), findNumberByName(nodeData.getNextStation()), cost));
+ }
+ }
+ }
+
+ private static String findNameByNumber(int number) {
+ return StationRepository.stations().get(number).getName();
+ }
+
+ private static int findNumberByName(String name) {
+ for (int i = 0; i < stationSize; i++) {
+ if (StationRepository.stations().get(i).getName().equals(name)) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ private static int selectDistanceOrTime(String select, NodeData nodeData) {
+ if (select.equals(Constants.FUNCTION_ONE)) {
+ return nodeData.getDistanceCost();
+ }
+ if (select.equals(Constants.FUNCTION_TWO)) {
+ return nodeData.getTimeCost();
+ }
+
+ return 0;
+ }
+
+ public static class Pair implements Comparable {
+ int s, e, cost;
+
+ Pair(int s, int e, int cost) {
+ this.s = s;
+ this.e = e;
+ this.cost = cost;
+ }
+
+ @Override
+ public int compareTo(Pair o) {
+ // TODO Auto-generated method stub
+ return this.cost - o.cost;
+ }
+ }
+}
From 597caf949b6620a22aeb1edf0d317e737cd238c7 Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 17:04:35 +0900
Subject: [PATCH 14/25] =?UTF-8?q?feat:=20=EB=8B=A4=EC=9D=B5=EC=8A=A4?=
=?UTF-8?q?=ED=8A=B8=EB=9D=BC=EB=A5=BC=20=EC=9D=B4=EC=9A=A9=ED=95=98?=
=?UTF-8?q?=EC=97=AC=20=EC=B5=9C=EB=8B=A8=20=EA=B1=B0=EB=A6=AC,=20?=
=?UTF-8?q?=EC=B5=9C=EC=86=8C=20=EC=8B=9C=EA=B0=84=20=EA=B5=AC=ED=95=98?=
=?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/FindPath.java | 57 ++++++++++++++++++++++++++----
1 file changed, 50 insertions(+), 7 deletions(-)
diff --git a/src/main/java/subway/FindPath.java b/src/main/java/subway/FindPath.java
index 4ccfa5084..8f8f9b780 100644
--- a/src/main/java/subway/FindPath.java
+++ b/src/main/java/subway/FindPath.java
@@ -6,24 +6,66 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.PriorityQueue;
public class FindPath {
+ private static final int INIT_MIN_VALUE = 0;
+ private static final int MAX_VALUE = 99999999;
private static ArrayList> subwayList;
private static int dist[];
+ private static boolean visited[];
private static int stationSize;
+ private static PriorityQueue q;
public static void start(String select, String startStation, String arriveStation) {
- setBeforeDijkstra(select);
+ setBeforeDijkstra(select, startStation);
+ int value = startDijkstra(startStation, arriveStation);
+ System.out.println(value);
+ if(value == MAX_VALUE){
+ throw new IllegalArgumentException("[ERROR] ์ฐ๊ฒฐ๋์ด ์์ง ์์ ์ญ์
๋๋ค.");
+ }
+ System.out.println(value);
}
- private static void setBeforeDijkstra(String select) {
+ //depth 2์ดํ๋ก ๊ณ ์น๊ธฐ, ๋ฉ์๋ 15์ค ์ดํ
+ private static int startDijkstra(String startStation, String arriveStation) {
+ int startNumber = findNumberByName(startStation);
+ int arriveNumber = findNumberByName(arriveStation);
+ dist[startNumber] = INIT_MIN_VALUE;
+ visited[startNumber] = true;
+
+ while(!q.isEmpty()){
+ Pair p = q.poll();
+
+ int start = p.start;
+
+ for(int i=0;i dist[start] + cost){
+ dist[end] = dist[start] + cost;
+ q.add(new Pair(end, 0, dist[end]));
+ }
+ }
+ }
+ visited[start] = true;
+ }
+
+ return dist[arriveNumber];
+ }
+
+ private static void setBeforeDijkstra(String select, String startStation) {
subwayList = new ArrayList>();
stationSize = StationRepository.getSize();
setSubwayList(select);
dist = new int[stationSize];
+ visited = new boolean[stationSize];
+ Arrays.fill(dist, MAX_VALUE);
+ q = new PriorityQueue<>();
- Arrays.fill(dist, Integer.MAX_VALUE);
+ q.add(new Pair(findNumberByName(startStation), 0, 0));
}
private static void setSubwayList(String select) {
@@ -46,6 +88,7 @@ private static String findNameByNumber(int number) {
private static int findNumberByName(String name) {
for (int i = 0; i < stationSize; i++) {
+
if (StationRepository.stations().get(i).getName().equals(name)) {
return i;
}
@@ -66,11 +109,11 @@ private static int selectDistanceOrTime(String select, NodeData nodeData) {
}
public static class Pair implements Comparable {
- int s, e, cost;
+ int start, end, cost;
- Pair(int s, int e, int cost) {
- this.s = s;
- this.e = e;
+ Pair(int start, int end, int cost) {
+ this.start = start;
+ this.end = end;
this.cost = cost;
}
From 62d9cdb8720cbcf81d3d10b30d731990f8cfef3f Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 17:04:55 +0900
Subject: [PATCH 15/25] =?UTF-8?q?feat:=20=ED=95=B4=EB=8B=B9=20=EC=97=AD?=
=?UTF-8?q?=EC=9D=B4=20=ED=8F=AC=ED=95=A8=EB=90=98=EC=96=B4=EC=9E=88?=
=?UTF-8?q?=EB=8A=94=EC=A7=80=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/domain/Station.java | 2 +-
src/main/java/subway/domain/StationRepository.java | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/main/java/subway/domain/Station.java b/src/main/java/subway/domain/Station.java
index d5354dbcd..a87c0f193 100644
--- a/src/main/java/subway/domain/Station.java
+++ b/src/main/java/subway/domain/Station.java
@@ -18,7 +18,7 @@ public String getName() {
// ์ถ๊ฐ ๊ธฐ๋ฅ ๊ตฌํ
public void addNodeData(String nextStation, int timeCost, int distanceCost){
- nodeData.add(new NodeData(new Station(nextStation), timeCost, distanceCost));
+ nodeData.add(new NodeData(new Station(name), new Station(nextStation), timeCost, distanceCost));
}
public List getNodeData(){
diff --git a/src/main/java/subway/domain/StationRepository.java b/src/main/java/subway/domain/StationRepository.java
index 3cb363b92..bce986fb1 100644
--- a/src/main/java/subway/domain/StationRepository.java
+++ b/src/main/java/subway/domain/StationRepository.java
@@ -24,6 +24,20 @@ public static void deleteAll() {
stations.clear();
}
+ public static boolean isContain(String name) {
+ for (Station station : stations) {
+ if (station.getName().equals(name)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public static int getSize() {
+ return stations.size();
+ }
+
public static void setCost(String prevStationName, String nextStationName, int timeCost, int distanceCost) {
for (int i = 0; i < stations.size(); i++) {
if (stations.get(i).getName().equals(prevStationName)) {
From 030f04bda9e6e8997e3aaf9e8d43c74b74bedcf5 Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 17:05:24 +0900
Subject: [PATCH 16/25] =?UTF-8?q?feat:=20NodeData=EC=97=90=EC=84=9C=20?=
=?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=EB=A5=BC=20=EA=B0=80=EC=A0=B8?=
=?UTF-8?q?=EC=98=A4=EB=8A=94=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94?=
=?UTF-8?q?=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/domain/NodeData.java | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/main/java/subway/domain/NodeData.java b/src/main/java/subway/domain/NodeData.java
index 23abd301d..c3a22c9cb 100644
--- a/src/main/java/subway/domain/NodeData.java
+++ b/src/main/java/subway/domain/NodeData.java
@@ -1,13 +1,31 @@
package subway.domain;
public class NodeData {
+ private Station beforeStation;
private Station nextStation;
private int timeCost;
private int distanceCost;
- public NodeData(Station nextStation, int timeCost, int distanceCost){
+ public NodeData(Station beforeStation, Station nextStation, int timeCost, int distanceCost) {
+ this.beforeStation = beforeStation;
this.nextStation = nextStation;
this.timeCost = timeCost;
this.distanceCost = distanceCost;
}
+
+ public String getBeforeStation() {
+ return beforeStation.getName();
+ }
+
+ public String getNextStation() {
+ return nextStation.getName();
+ }
+
+ public int getTimeCost() {
+ return timeCost;
+ }
+
+ public int getDistanceCost() {
+ return distanceCost;
+ }
}
From e0c1c17fae04931135dceafdb468add5c574d76c Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 17:06:10 +0900
Subject: [PATCH 17/25] =?UTF-8?q?docs:=20README.md=EC=97=90=20=EC=98=88?=
=?UTF-8?q?=EC=99=B8=EC=82=AC=ED=95=AD=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index a98d068c2..1654bf6e1 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@
- ๋ฉ์ธ ํ๋ฉด์์ ๊ธฐ๋ฅ ์ ํ
- ์์ธ ์ฒ๋ฆฌ : ์ ํ ๊ฐ๋ฅํ์ง ์์ ๊ธฐ๋ฅ ๋ฒํธ ์
๋ ฅ
- ์ถ๋ฐ์ญ, ๋์ฐฉ์ญ ์
๋ ฅ๋ฐ๊ธฐ
- - ์ญ ๋ชฉ๋ก์ ์กด์ฌํ์ง ์๋ ์
๋ ฅ
+ - ์์ธ ์ฒ๋ฆฌ : ์ญ ๋ชฉ๋ก์ ์กด์ฌํ์ง ์๋ ์
๋ ฅ, ๊ฐ์ ์ด๋ฆ์ ์ญ์ ๋ฐ์ ๊ฒฝ์ฐ
- ๊ฒฝ๋ก ์กฐํ ์ ๊ฑฐ๋ฆฌ, ์๊ฐ ๊ธฐ์ค
- ์ด ๊ฑฐ๋ฆฌ, ์ด ์์์๊ฐ, ์ง๋์จ ๊ตฌ๊ฐ ์ถ๋ ฅ
- ๋ค์ต์คํธ๋ผ๋ฅผ ํ์ฉํ์ฌ ๊ฒฝ๋ก ๊ตฌํ๊ธฐ
\ No newline at end of file
From cf5d8780420a89d82e28e9af103e72e1d4824e3b Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 17:31:39 +0900
Subject: [PATCH 18/25] =?UTF-8?q?feat:=20=EC=97=90=EB=9F=AC=20=EC=BD=94?=
=?UTF-8?q?=EB=93=9C=20=EC=83=81=EC=88=98=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/Constants.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/main/java/subway/Constants.java b/src/main/java/subway/Constants.java
index c958b67ef..fe3b5322c 100644
--- a/src/main/java/subway/Constants.java
+++ b/src/main/java/subway/Constants.java
@@ -5,4 +5,7 @@ public class Constants {
public static final String FUNCTION_TWO = "2";
public static final String FUNCTION_Q = "Q";
public static final String FUNCTION_B = "B";
+ public static final String TIME_COST = "TIME";
+ public static final String DISTANCE_COST = "DISTANCE";
+ public static final int ERROR_CODE = -1;
}
From a6032a102e3283e41f4afcdd548da9c975887b04 Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 17:31:54 +0900
Subject: [PATCH 19/25] =?UTF-8?q?feat:=20=EC=B6=9C=EB=B0=9C=EC=97=AD?=
=?UTF-8?q?=EA=B3=BC=20=EB=8F=84=EC=B0=A9=EC=97=AD=EC=9D=B4=20=EA=B0=99?=
=?UTF-8?q?=EC=9D=84=EA=B2=BD=EC=9A=B0=20=EC=98=88=EC=99=B8=EC=B2=98?=
=?UTF-8?q?=EB=A6=AC=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/SubwayManagement.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/main/java/subway/SubwayManagement.java b/src/main/java/subway/SubwayManagement.java
index acd2a913e..43a2f4aa3 100644
--- a/src/main/java/subway/SubwayManagement.java
+++ b/src/main/java/subway/SubwayManagement.java
@@ -63,7 +63,7 @@ private void selectFindPathFunction(String select) {
String arriveStation = user.getInput();
try {
- checkContainStation(startStation, arriveStation);
+ checkFindPathInput(startStation, arriveStation);
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
return;
@@ -71,9 +71,12 @@ private void selectFindPathFunction(String select) {
FindPath.start(select, startStation, arriveStation);
}
- private void checkContainStation(String startStation, String arriveStation) {
+ private void checkFindPathInput(String startStation, String arriveStation) {
if (!StationRepository.isContain(startStation) || !StationRepository.isContain(arriveStation)) {
throw new IllegalArgumentException("[ERROR] ์กด์ฌํ์ง ์๋ ์ญ์
๋๋ค.\n");
}
+ if (startStation.equals(arriveStation)) {
+ throw new IllegalArgumentException("[ERROR] ์ถ๋ฐ์ญ๊ณผ ๋์ฐฉ์ญ์ ๊ฐ์ ์ ์์ต๋๋ค.\n");
+ }
}
}
From 194cc9ff1f06b8a98ebdf825932e5f2dbc5423ca Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 17:32:17 +0900
Subject: [PATCH 20/25] =?UTF-8?q?feat:=20=EB=91=90=20=EC=97=AD=20=EC=82=AC?=
=?UTF-8?q?=EC=9D=B4=EC=9D=98=20=EB=B9=84=EC=9A=A9=20=EA=B0=80=EC=A0=B8?=
=?UTF-8?q?=EC=98=A4=EB=8A=94=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94?=
=?UTF-8?q?=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/subway/domain/StationRepository.java | 31 +++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/src/main/java/subway/domain/StationRepository.java b/src/main/java/subway/domain/StationRepository.java
index bce986fb1..81f483c5c 100644
--- a/src/main/java/subway/domain/StationRepository.java
+++ b/src/main/java/subway/domain/StationRepository.java
@@ -1,5 +1,7 @@
package subway.domain;
+import subway.Constants;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -38,6 +40,35 @@ public static int getSize() {
return stations.size();
}
+ public static int getCost(String firstStation, String secondStation, String kind) {
+ for (Station station : stations) {
+ if (station.getName().equals(firstStation)) {
+ return findNextStation(station, secondStation, kind);
+ }
+ }
+ return Constants.ERROR_CODE;
+ }
+
+ private static int findNextStation(Station station, String nextStation, String kind) {
+ for (NodeData nodeData : station.getNodeData()) {
+ if (nodeData.getNextStation().equals(nextStation)) {
+ return getTimeOrDistanceCost(nodeData, kind);
+ }
+ }
+ return Constants.ERROR_CODE;
+ }
+
+ private static int getTimeOrDistanceCost(NodeData nodeData, String kind) {
+ if (kind.equals(Constants.DISTANCE_COST)) {
+ return nodeData.getDistanceCost();
+ }
+ if (kind.equals(Constants.TIME_COST)) {
+ return nodeData.getTimeCost();
+ }
+
+ return Constants.ERROR_CODE;
+ }
+
public static void setCost(String prevStationName, String nextStationName, int timeCost, int distanceCost) {
for (int i = 0; i < stations.size(); i++) {
if (stations.get(i).getName().equals(prevStationName)) {
From 67dd403e7905c7a154529c2e6c95dd10e4731f47 Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 17:45:34 +0900
Subject: [PATCH 21/25] =?UTF-8?q?feat:=20=EC=B5=9C=EB=8B=A8=20=EA=B1=B0?=
=?UTF-8?q?=EB=A6=AC,=20=EC=B5=9C=EC=86=8C=20=EB=B9=84=EC=9A=A9=20?=
=?UTF-8?q?=EA=B5=AC=ED=95=98=EB=8A=94=20=EB=A9=94=EC=86=8C=EB=93=9C?=
=?UTF-8?q?=EC=99=80=20=EC=A7=80=EB=82=98=EA=B0=80=EB=8A=94=20=EC=97=AD=20?=
=?UTF-8?q?=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/FindPath.java | 58 ++++++++++++++++++++++++------
1 file changed, 47 insertions(+), 11 deletions(-)
diff --git a/src/main/java/subway/FindPath.java b/src/main/java/subway/FindPath.java
index 8f8f9b780..74fcfdb5b 100644
--- a/src/main/java/subway/FindPath.java
+++ b/src/main/java/subway/FindPath.java
@@ -7,25 +7,59 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
+import java.util.Stack;
public class FindPath {
private static final int INIT_MIN_VALUE = 0;
private static final int MAX_VALUE = 99999999;
+
private static ArrayList> subwayList;
private static int dist[];
private static boolean visited[];
+ private static int parent[];
private static int stationSize;
private static PriorityQueue q;
public static void start(String select, String startStation, String arriveStation) {
setBeforeDijkstra(select, startStation);
- int value = startDijkstra(startStation, arriveStation);
- System.out.println(value);
- if(value == MAX_VALUE){
- throw new IllegalArgumentException("[ERROR] ์ฐ๊ฒฐ๋์ด ์์ง ์์ ์ญ์
๋๋ค.");
+ int minCost = startDijkstra(startStation, arriveStation);
+ if (minCost == MAX_VALUE) {
+ throw new IllegalArgumentException("[ERROR] ์๋ก ์ฐ๊ฒฐ๋์ด ์์ง ์์ ์ญ์
๋๋ค.");
+ }
+
+ int anotherMinCost = traceMinCost(findNumberByName(startStation), findNumberByName(arriveStation), select);
+ Stack stack = tracePath(findNumberByName(startStation), findNumberByName(arriveStation));
+
+ }
+
+ private static int traceMinCost(int startNumber, int endNumber, String kind) {
+ if (kind.equals(Constants.FUNCTION_ONE)) {
+ kind = Constants.TIME_COST;
+ }
+ if (kind.equals(Constants.FUNCTION_TWO)) {
+ kind = Constants.DISTANCE_COST;
+ }
+ int minCost = 0;
+ int cur = endNumber;
+
+ while (cur != startNumber) {
+ minCost += StationRepository.getCost(findNameByNumber(cur), findNameByNumber(parent[cur]), kind);
+ cur = parent[cur];
+ }
+ return minCost;
+ }
+
+ private static Stack tracePath(int startNumber, int endNumber) {
+ Stack stack = new Stack<>();
+ int cur = endNumber;
+
+ while (cur != startNumber) {
+ stack.push(findNameByNumber(cur));
+ cur = parent[cur];
}
- System.out.println(value);
+ stack.push(findNameByNumber(cur));
+ return stack;
}
//depth 2์ดํ๋ก ๊ณ ์น๊ธฐ, ๋ฉ์๋ 15์ค ์ดํ
@@ -35,18 +69,19 @@ private static int startDijkstra(String startStation, String arriveStation) {
dist[startNumber] = INIT_MIN_VALUE;
visited[startNumber] = true;
- while(!q.isEmpty()){
+ while (!q.isEmpty()) {
Pair p = q.poll();
int start = p.start;
- for(int i=0;i dist[start] + cost){
+ if (!visited[end]) {
+ if (dist[end] > dist[start] + cost) {
dist[end] = dist[start] + cost;
q.add(new Pair(end, 0, dist[end]));
+ parent[end] = start;
}
}
}
@@ -62,6 +97,7 @@ private static void setBeforeDijkstra(String select, String startStation) {
setSubwayList(select);
dist = new int[stationSize];
visited = new boolean[stationSize];
+ parent = new int[stationSize];
Arrays.fill(dist, MAX_VALUE);
q = new PriorityQueue<>();
@@ -94,7 +130,7 @@ private static int findNumberByName(String name) {
}
}
- return -1;
+ return Constants.ERROR_CODE;
}
private static int selectDistanceOrTime(String select, NodeData nodeData) {
@@ -105,7 +141,7 @@ private static int selectDistanceOrTime(String select, NodeData nodeData) {
return nodeData.getTimeCost();
}
- return 0;
+ return Constants.ERROR_CODE;
}
public static class Pair implements Comparable {
From 66672cb4b02e6e854e170f06dd70c6b6adf2e0ca Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 17:52:46 +0900
Subject: [PATCH 22/25] =?UTF-8?q?feat:=20=EA=B2=BD=EB=A1=9C=20=EC=A1=B0?=
=?UTF-8?q?=ED=9A=8C=EC=8B=9C=20=EC=B6=9C=EB=A0=A5=20=EA=B8=B0=EB=8A=A5=20?=
=?UTF-8?q?=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/PrintScreen.java | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/src/main/java/subway/PrintScreen.java b/src/main/java/subway/PrintScreen.java
index 71735b278..99185332c 100644
--- a/src/main/java/subway/PrintScreen.java
+++ b/src/main/java/subway/PrintScreen.java
@@ -1,5 +1,7 @@
package subway;
+import java.util.Stack;
+
public class PrintScreen {
public static void printMain() {
@@ -11,7 +13,7 @@ public static void printMain() {
}
public static void selectFunction() {
- System.out.println("## ์ํ๋ ๊ธฐ๋ฅ์ ์ ํํ์ธ์.");
+ System.out.println("\n## ์ํ๋ ๊ธฐ๋ฅ์ ์ ํํ์ธ์.");
}
public static void selectStandard() {
@@ -30,4 +32,21 @@ public static void printInputStartStation() {
public static void printInputArriveStation() {
System.out.println("## ๋์ฐฉ์ญ์ ์
๋ ฅํ์ธ์.");
}
+
+ public static void printMinPathStationToArrive(String kind, Stack stack, int firstMinCost, int secondMinCost) {
+ System.out.println("[INFO] ---");
+ if (kind.equals(Constants.DISTANCE_COST)) {
+ System.out.println("[INFO] ์ด ๊ฑฐ๋ฆฌ : " + firstMinCost);
+ System.out.println("[INFO] ์ด ์์์๊ฐ : " + secondMinCost);
+ }
+ if (kind.equals(Constants.TIME_COST)) {
+ System.out.println("[INFO] ์ด ์์์๊ฐ : " + firstMinCost);
+ System.out.println("[INFO] ์ด ๊ฑฐ๋ฆฌ : " + secondMinCost);
+ }
+ System.out.println("[INFO] ---");
+ while (!stack.isEmpty()) {
+ System.out.println("[INFO] " + stack.pop());
+ }
+ System.out.println();
+ }
}
From 26350f8e399017d27fd96014b132e13466970431 Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 17:53:20 +0900
Subject: [PATCH 23/25] =?UTF-8?q?feat:=20=EA=B2=BD=EB=A1=9C=20=EC=A1=B0?=
=?UTF-8?q?=ED=9A=8C=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/FindPath.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/main/java/subway/FindPath.java b/src/main/java/subway/FindPath.java
index 74fcfdb5b..8d318e2ed 100644
--- a/src/main/java/subway/FindPath.java
+++ b/src/main/java/subway/FindPath.java
@@ -27,10 +27,13 @@ public static void start(String select, String startStation, String arriveStatio
if (minCost == MAX_VALUE) {
throw new IllegalArgumentException("[ERROR] ์๋ก ์ฐ๊ฒฐ๋์ด ์์ง ์์ ์ญ์
๋๋ค.");
}
-
+ String kind = Constants.DISTANCE_COST;
+ if (select.equals(Constants.FUNCTION_TWO)) {
+ kind = Constants.TIME_COST;
+ }
int anotherMinCost = traceMinCost(findNumberByName(startStation), findNumberByName(arriveStation), select);
Stack stack = tracePath(findNumberByName(startStation), findNumberByName(arriveStation));
-
+ PrintScreen.printMinPathStationToArrive(kind, stack, minCost, anotherMinCost);
}
private static int traceMinCost(int startNumber, int endNumber, String kind) {
From 52427195f28411859e009b4f65a01ae1097237d2 Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 17:53:54 +0900
Subject: [PATCH 24/25] =?UTF-8?q?feat:=20SubwayMangement=20=EA=B0=9D?=
=?UTF-8?q?=EC=B2=B4=20=EC=83=9D=EC=84=B1,=20=EB=A9=94=EC=9D=B8=20?=
=?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/Application.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/main/java/subway/Application.java b/src/main/java/subway/Application.java
index 0bcf786cc..65a95c9a9 100644
--- a/src/main/java/subway/Application.java
+++ b/src/main/java/subway/Application.java
@@ -6,5 +6,8 @@ public class Application {
public static void main(String[] args) {
final Scanner scanner = new Scanner(System.in);
// TODO: ํ๋ก๊ทธ๋จ ๊ตฌํ
+ User user = new User(scanner);
+ SubwayManagement subwayManagement = new SubwayManagement(user);
+ subwayManagement.start();
}
}
From 2856294059aa0736676d6a1338c69be2d0e8cc2e Mon Sep 17 00:00:00 2001
From: pika96 <52442949+pika96@users.noreply.github.com>
Date: Sat, 19 Dec 2020 17:56:54 +0900
Subject: [PATCH 25/25] =?UTF-8?q?feat:=20=EC=97=B0=EA=B2=B0=EB=90=98?=
=?UTF-8?q?=EC=96=B4=EC=9E=88=EC=A7=80=20=EC=95=8A=EC=9D=80=20=EC=97=AD?=
=?UTF-8?q?=EC=9D=BC=20=EA=B2=BD=EC=9A=B0=20=EC=97=90=EB=9F=AC=20=EC=B6=94?=
=?UTF-8?q?=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/subway/SubwayManagement.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/subway/SubwayManagement.java b/src/main/java/subway/SubwayManagement.java
index 43a2f4aa3..21ed09e17 100644
--- a/src/main/java/subway/SubwayManagement.java
+++ b/src/main/java/subway/SubwayManagement.java
@@ -64,11 +64,11 @@ private void selectFindPathFunction(String select) {
try {
checkFindPathInput(startStation, arriveStation);
+ FindPath.start(select, startStation, arriveStation);
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
return;
}
- FindPath.start(select, startStation, arriveStation);
}
private void checkFindPathInput(String startStation, String arriveStation) {