Skip to content

Commit 9d1e391

Browse files
authored
CodeSandboxに表示される解答が更新されていなかったため、更新 (#745)
1 parent 0420b76 commit 9d1e391

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

docs/2-browser-apps/03-class/_samples/inheritance-class-SeniorStudent/script.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ class Student {
22
name;
33
age;
44

5+
constructor(name, age) {
6+
this.name = name;
7+
this.age = age;
8+
}
9+
510
introduceSelf() {
611
document.write(`私の名前は${this.name}です。${this.age}歳です。`);
712
}
@@ -10,14 +15,15 @@ class Student {
1015
class SeniorStudent extends Student {
1116
researchQuestion;
1217

18+
constructor(name, age, researchQuestion) {
19+
super(name, age);
20+
this.researchQuestion = researchQuestion;
21+
}
22+
1323
introduceSelf() {
1424
super.introduceSelf();
1525
document.write(`研究テーマは${this.researchQuestion}です。`);
1626
}
1727
}
18-
19-
const tanaka = new SeniorStudent();
20-
tanaka.age = 22;
21-
tanaka.name = "田中";
22-
tanaka.researchQuestion = "量子力学";
28+
const tanaka = new SeniorStudent("田中", 22, "量子力学");
2329
tanaka.introduceSelf();

docs/2-browser-apps/03-class/_samples/method-incrementAge/script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Student {
1212

1313
const tanaka = new Student();
1414
tanaka.name = "田中";
15-
tanaka.age = 18;
15+
tanaka.age = 19;
1616
tanaka.introduceSelf();
1717
tanaka.incrementAge();
1818
tanaka.introduceSelf();

docs/2-browser-apps/03-class/index.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,15 @@ tanaka.introduceSelf();
119119
class Student {
120120
name;
121121
age;
122+
122123
introduceSelf() {
123124
document.write(`私の名前は${this.name}です。${this.age}歳です。`);
124125
}
125126
incrementAge() {
126127
this.age += 1;
127128
}
128129
}
130+
129131
const tanaka = new Student();
130132
tanaka.name = "田中";
131133
tanaka.age = 19;
@@ -296,6 +298,7 @@ class Student {
296298
document.write(`私の名前は${this.name}です。${this.age}歳です。`);
297299
}
298300
}
301+
299302
class SeniorStudent extends Student {
300303
researchQuestion;
301304

0 commit comments

Comments
 (0)