File tree 1 file changed +33
-2
lines changed
Roadmap/08 - CLASES/javascript
1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -85,10 +85,41 @@ class Pila {
85
85
}
86
86
}
87
87
88
-
89
88
const pila = new Pila ( ) ;
90
89
pila . push ( "hola" ) ;
91
90
pila . push ( "mundo" ) ;
92
91
pila . push ( "!" ) ;
93
92
console . log ( pila . print ( ) ) ;
94
- console . log ( pila . size ( ) ) ;
93
+ console . log ( pila . size ( ) ) ;
94
+
95
+ class Cola {
96
+ constructor ( ) {
97
+ this . cola = [ ] ;
98
+ }
99
+
100
+ encolar ( elemento ) {
101
+ this . cola . push ( elemento ) ;
102
+ }
103
+
104
+ desencolar ( ) {
105
+ this . cola . shift ( ) ;
106
+ }
107
+
108
+ size ( ) {
109
+ return this . cola . length ;
110
+ }
111
+
112
+ print ( ) {
113
+ return this . cola ;
114
+ }
115
+ }
116
+
117
+ const cola = new Cola ( ) ;
118
+ cola . encolar ( "hola" ) ;
119
+ cola . encolar ( "mundo" ) ;
120
+ cola . encolar ( "!" ) ;
121
+ cola . encolar ( "Soy" ) ;
122
+ cola . encolar ( "una" ) ;
123
+ cola . encolar ( "cola" ) ;
124
+ console . log ( cola . print ( ) ) ;
125
+ console . log ( cola . size ( ) ) ;
You can’t perform that action at this time.
0 commit comments