This repository was archived by the owner on May 28, 2022. It is now read-only.
File tree 2 files changed +73
-0
lines changed
2 files changed +73
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < body >
4
+
5
+ < h1 > Tree</ h1 >
6
+
7
+ < pre id ="category ">
8
+
9
+ </ div >
10
+ < script src ="tree.js ">
11
+
12
+ </ script >
13
+ </ body >
14
+ </ html >
15
+
Original file line number Diff line number Diff line change
1
+ class Node {
2
+ constructor ( title , id , parent ) {
3
+ this . title = title
4
+ this . id = id
5
+ this . parent = parent
6
+ }
7
+
8
+ setParent ( parent ) {
9
+ this . parent = parent
10
+ }
11
+
12
+ eClick ( ) {
13
+ console . log ( this . id + ' Clicked' ) ;
14
+ }
15
+ }
16
+
17
+ class Row {
18
+
19
+ constructor ( ) {
20
+ this . nodes = new Array ( )
21
+ }
22
+ appendNode ( node ) {
23
+ this . nodes . push ( node )
24
+ }
25
+ deleteNode ( node ) {
26
+ this . nodes . remove ( node )
27
+ }
28
+
29
+ getNodes ( ) {
30
+ return this . nodes
31
+ }
32
+ }
33
+
34
+ /**********
35
+
36
+ A-->B
37
+ C-->D
38
+ E-->F
39
+ G-->H
40
+
41
+ ***********/
42
+ A = new Node ( 'A' , 1 , null )
43
+ // B = new Node('B', 2, 1)
44
+ // C = new Node('C', 3, 1)
45
+ // D = new Node('D', 4, 3)
46
+ // E = new Node('E', 5, 1)
47
+
48
+ G = new Node ( 'G' , 6 , null )
49
+ // H = new Node('H', 7, 6)
50
+
51
+
52
+
53
+ row = new Row ( )
54
+ row . appendNode ( A )
55
+ row . appendNode ( G )
56
+
57
+ console . log ( row ) ;
58
+ document . getElementById ( "category" ) . innerHTML = JSON . stringify ( row . getNodes ( ) , null , 2 ) ;
You can’t perform that action at this time.
0 commit comments