File tree Expand file tree Collapse file tree 10 files changed +107
-139
lines changed Expand file tree Collapse file tree 10 files changed +107
-139
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- load ( "Dictionary.js" ) ;
2- var pbook = new Dictionary ( ) ;
3- pbook . add ( "Mike" , "123" ) ;
4- pbook . add ( "David" , "345" ) ;
5- pbook . add ( "Cynthia" , "456" ) ;
6- print ( "David's extension: " + pbook . find ( "David" ) ) ;
7- pbook . remove ( "David" ) ;
1+ load ( "Dictionary.js" ) ;
2+ var pbook = new Dictionary ( ) ;
3+ pbook . add ( "Mike" , "123" ) ;
4+ pbook . add ( "David" , "345" ) ;
5+ pbook . add ( "Cynthia" , "456" ) ;
6+ print ( "David's extension: " + pbook . find ( "David" ) ) ;
7+ pbook . remove ( "David" ) ;
88pbook . showAll ( ) ;
Original file line number Diff line number Diff line change 1- function Dictionary ( ) {
2- this . add = add ;
3- this . datastore = new Array ( ) ;
4- this . find = find ;
5- this . remove = remove ;
6- this . showAll = showAll ;
7- this . count = count ;
8- this . clear = clear ;
9- }
10-
11- function add ( key , value ) {
12- this . datastore [ key ] = value ;
13- }
14-
15- function find ( key ) {
16- return this . datastore [ key ] ;
17- }
18-
19- function remove ( key ) {
20- delete this . datastore [ key ] ;
21- }
22-
23- function showAll ( ) {
24- for ( var key in Object . keys ( this . datastore ) . sort ( ) ) {
25- print ( key + " -> " + this . datastore [ key ] ) ;
26- }
27- }
28-
29- function count ( ) {
30- var n = 0 ;
31- for ( var key in Object . keys ( this . datastore ) ) {
32- ++ n ;
33- }
34- return n ;
35- }
36-
37- function clear ( ) {
38- for ( var key in Object . keys ( this . datastore ) ) {
39- delete this . datastore [ key ] ;
40- }
41- }
1+ function Dictionary ( ) {
2+ this . add = add ;
3+ this . datastore = new Array ( ) ;
4+ this . find = find ;
5+ this . remove = remove ;
6+ this . showAll = showAll ;
7+ this . count = count ;
8+ this . clear = clear ;
9+ }
10+
11+ function add ( key , value ) {
12+ this . datastore [ key ] = value ;
13+ }
14+
15+ function find ( key ) {
16+ return this . datastore [ key ] ;
17+ }
18+
19+ function remove ( key ) {
20+ delete this . datastore [ key ] ;
21+ }
22+
23+ function showAll ( ) {
24+ for ( var key in Object . keys ( this . datastore ) . sort ( ) ) {
25+ print ( key + " -> " + this . datastore [ key ] ) ;
26+ }
27+ }
28+
29+ function count ( ) {
30+ var n = 0 ;
31+ for ( var key in Object . keys ( this . datastore ) ) {
32+ ++ n ;
33+ }
34+ return n ;
35+ }
36+
37+ function clear ( ) {
38+ for ( var key in Object . keys ( this . datastore ) ) {
39+ delete this . datastore [ key ] ;
40+ }
41+ }
Original file line number Diff line number Diff line change 1- load ( "Dictionary.js" ) ;
2- var pbook = new Dictionary ( ) ;
3- pbook . add ( "Raymond" , "123" ) ;
4- pbook . add ( "David" , "345" ) ;
5- pbook . add ( "Cynthia" , "456" ) ;
6- print ( "Number of entries: " + pbook . count ( ) ) ;
7- print ( "David's extension: " + pbook . find ( "David" ) ) ;
8- pbook . showAll ( ) ;
9- pbook . clear ( ) ;
1+ load ( "Dictionary.js" ) ;
2+ var pbook = new Dictionary ( ) ;
3+ pbook . add ( "Raymond" , "123" ) ;
4+ pbook . add ( "David" , "345" ) ;
5+ pbook . add ( "Cynthia" , "456" ) ;
6+ print ( "Number of entries: " + pbook . count ( ) ) ;
7+ print ( "David's extension: " + pbook . find ( "David" ) ) ;
8+ pbook . showAll ( ) ;
9+ pbook . clear ( ) ;
1010print ( "Number of entries: " + pbook . count ( ) ) ;
Original file line number Diff line number Diff line change 1- load ( "Dictionary.js" ) ;
2- var pbook = new Dictionary ( ) ;
3- pbook . add ( "Raymond" , "123" ) ;
4- pbook . add ( "David" , "345" ) ;
5- pbook . add ( "Cynthia" , "456" ) ;
6- pbook . add ( "Mike" , "723" ) ;
7- pbook . add ( "Jennifer" , "987" ) ;
8- pbook . add ( "Danny" , "012" ) ;
9- pbook . add ( "Jonathan" , "666" ) ;
1+ load ( "Dictionary.js" ) ;
2+ var pbook = new Dictionary ( ) ;
3+ pbook . add ( "Raymond" , "123" ) ;
4+ pbook . add ( "David" , "345" ) ;
5+ pbook . add ( "Cynthia" , "456" ) ;
6+ pbook . add ( "Mike" , "723" ) ;
7+ pbook . add ( "Jennifer" , "987" ) ;
8+ pbook . add ( "Danny" , "012" ) ;
9+ pbook . add ( "Jonathan" , "666" ) ;
1010pbook . showAll ( ) ;
Original file line number Diff line number Diff line change 1- function Dictionary ( ) {
2- this . add = add ;
3- this . datastore = new Array ( ) ;
4- this . find = find ;
5- this . remove = remove ;
6- this . showAll = showAll ;
7- this . count = count ;
8- this . clear = clear ;
9- }
10-
11- function add ( key , value ) {
12- this . datastore [ key ] = value ;
13- }
14-
15- function find ( key ) {
16- return this . datastore [ key ] ;
17- }
18-
19- function remove ( key ) {
20- delete this . datastore [ key ] ;
21- }
22-
23- function showAll ( ) {
24- for ( var key in Object . keys ( this . datastore ) . sort ( ) ) {
25- print ( key + " -> " + this . datastore [ key ] ) ;
26- }
27- }
28-
29- function count ( ) {
30- var n = 0 ;
31- for ( var key in Object . keys ( this . datastore ) ) {
32- ++ n ;
33- }
34- return n ;
35- }
36-
37- function clear ( ) {
38- for ( var key in Object . keys ( this . datastore ) ) {
39- delete this . datastore [ key ] ;
40- }
41- }
1+ function Dictionary ( ) {
2+ this . add = add ;
3+ this . datastore = new Array ( ) ;
4+ this . find = find ;
5+ this . remove = remove ;
6+ this . showAll = showAll ;
7+ this . count = count ;
8+ this . clear = clear ;
9+ }
10+
11+ function add ( key , value ) {
12+ this . datastore [ key ] = value ;
13+ }
14+
15+ function find ( key ) {
16+ return this . datastore [ key ] ;
17+ }
18+
19+ function remove ( key ) {
20+ delete this . datastore [ key ] ;
21+ }
22+
23+ function showAll ( ) {
24+ for ( var key in Object . keys ( this . datastore ) . sort ( ) ) {
25+ print ( key + " -> " + this . datastore [ key ] ) ;
26+ }
27+ }
28+
29+ function count ( ) {
30+ var n = 0 ;
31+ for ( var key in Object . keys ( this . datastore ) ) {
32+ ++ n ;
33+ }
34+ return n ;
35+ }
36+
37+ function clear ( ) {
38+ for ( var key in Object . keys ( this . datastore ) ) {
39+ delete this . datastore [ key ] ;
40+ }
41+ }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments