Skip to content

Commit d3b2019

Browse files
author
何炜
committed
修改文件名称
1 parent 8797780 commit d3b2019

File tree

10 files changed

+107
-139
lines changed

10 files changed

+107
-139
lines changed

Chapter1/chapter1.js

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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");
88
pbook.showAll();
Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,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-
}
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+
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
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();
1010
print("Number of entries: " + pbook.count());
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
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");
1010
pbook.showAll();
Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,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-
}
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.

0 commit comments

Comments
 (0)