-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
844eff0
commit 70b9de0
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { TreeNode } from "./TreeNode"; | ||
|
||
export const BallGameRoot = new TreeNode.Builder("구기/비구기") | ||
.setLeft( | ||
new TreeNode.Builder("역시 체육은 공놀이지") | ||
.setLeft( | ||
new TreeNode.Builder("운동은 좀 복작복작 해야지") | ||
.setLeft( | ||
new TreeNode.Builder("좀 부딪히는게 재밌지") | ||
.setValue(["센토", "맨투맨", "동그라미", "오렌지파이터스"]) | ||
.build(), | ||
) | ||
.setRight( | ||
new TreeNode.Builder("내 몸에 손대지 마!!") | ||
.setValue(["스트라이크", "파란", "스파이크"]) | ||
.build(), | ||
) | ||
.build(), | ||
) | ||
.setRight( | ||
new TreeNode.Builder("꼭 사람이 많을 필요는 없지") | ||
.setLeft( | ||
new TreeNode.Builder("내 눈을 바라봐. 난 당신 얼굴이 궁금하다.") | ||
.setValue(["KUTC", "스매싱", "스윙스"]) | ||
.build(), | ||
) | ||
.setRight(new TreeNode.Builder("난 앞만 봐.").setValue(["KGA", "KNUBC"]).build()) | ||
.build(), | ||
) | ||
.build(), | ||
) | ||
.setRight( | ||
new TreeNode.Builder("응 아니야~") | ||
.setLeft(new TreeNode.Builder("장비 따위 필요 없어. 최고의 장비는 바로 나!").build()) | ||
.setRight(new TreeNode.Builder("인간은 도구를 사용해야지!").build()) | ||
.build(), | ||
) | ||
.build(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
export class TreeNode { | ||
left: TreeNode | null; | ||
right: TreeNode | null; | ||
value: any; | ||
|
||
constructor(value: any) { | ||
this.left = null; | ||
this.right = null; | ||
this.value = value; | ||
} | ||
set setLeft(node: TreeNode) { | ||
this.left = node; | ||
} | ||
set setRight(node: TreeNode) { | ||
this.right = node; | ||
} | ||
get getValue() { | ||
return this.value; | ||
} | ||
|
||
static Builder = class Builder { | ||
private node: TreeNode; | ||
|
||
constructor(value: any) { | ||
this.node = new TreeNode(value); | ||
} | ||
setLeft(node: TreeNode): this { | ||
this.node.left = node; | ||
return this; | ||
} | ||
setRight(node: TreeNode): this { | ||
this.node.right = node; | ||
return this; | ||
} | ||
setValue(value: any): this { | ||
this.node.value = value; | ||
return this; | ||
} | ||
build(): TreeNode { | ||
return this.node; | ||
} | ||
}; | ||
} |