Skip to content

Commit d67593f

Browse files
author
Rafa Paradela
committed
Merge pull request scala-exercises#45 from fada21/master
Parent classes koan fix
2 parents d175b70 + f0d1bc7 commit d67593f

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

app/json/parentclasses.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,29 @@
33
"modules": [
44
{
55
"preparagraph": "In contrast to Java, all values in Scala are objects (including numerical values and functions). Since Scala is class-based, all values are instances of a class.\n\nClass hierarchy is linear, a class can only extend from one parent class:\n",
6-
"code": "class Worker(val firstName: String, val lastName: String) {}\nclass Employee(override val firstName: String, override val lastName: String,\n val employeeID: Long) extends Worker(firstName, lastName)\nval me = new Employee(\"Name\", \"Yourself\", 1233)\nme.firstName should be(__)\nme.lastName should be(__)",
6+
"code": "class Soldier(val firstName: String, val lastName: String) {}\nclass Pilot(override val firstName: String, override val lastName: String,\n val squadron: Long) extends Soldier(firstName, lastName)\nval pilot = new Pilot(\"John\", \"Yossarian\", 256)\npilot.firstName should be(__)\npilot.lastName should be(__)",
77
"solutions": [
8-
"\"Name\"",
9-
"\"Yourself\""
8+
"\"John\"",
9+
"\"Yossarian\""
1010
],
1111
"postparagraph": ""
1212
},
1313
{
1414
"preparagraph": "A class that extends from another is polymorphic:",
15-
"code": "class Worker(val firstName: String, val lastName: String) {}\nclass Employee(override val firstName: String, override val lastName: String,\n val employeeID: Long) extends Worker(firstName, lastName)\n\nval me = new Employee(\"Name\", \"Yourself\", 1233)\nval worker: Worker = me\n\nworker.firstName should be(__)\nworker.lastName should be(__)",
15+
"code": "class Soldier(val firstName: String, val lastName: String) {}\nclass Pilot(override val firstName: String, override val lastName: String,\n val squadron: Long) extends Soldier(firstName, lastName)\n\nval pilot = new Pilot(\"John\", \"Yossarian\", 256)\nval soldier: Soldier = pilot\n\nsoldier.firstName should be(__)\nsoldier.lastName should be(__)",
1616
"solutions": [
17-
"\"Name\"",
18-
"\"Yourself\""
17+
"\"John\"",
18+
"\"Yossarian\""
1919
],
2020
"postparagraph": ""
2121
},
2222
{
23-
"preparagraph": "An abstract class, as in Java, cannot be instantiated and only inherited:\n\n```\nabstract class Worker(val firstName: String, val lastName: String) {}\n\n// if you uncomment this line, if will fail compilation\n//val worker = new Worker\n```\n\nA class can be placed inside an abstract class just like in java:",
24-
"code": "abstract class Worker(val firstName: String, val lastName: String) {\n class Assignment(val hours: Long) {\n // nothing to do here. Just observe that it compiles\n }\n}\nclass Employee(override val firstName: String, override val lastName: String,\n val employeeID: Long) extends Worker(firstName, lastName)\n\nval employee = new Employee(\"Name\", \"Yourself\", 2291)\nval assignment = new employee.Assignment(__) //using the employee instance's path, create an assignment for it.\nassignment.hours should be (__)",
23+
"preparagraph": "An abstract class, as in Java, cannot be instantiated and only inherited:\n\n```\nabstract class Soldier(val firstName: String, val lastName: String) {}\n\n// if you uncomment this line, if will fail compilation\n//val soldier = new Soldier\n```\n\nA class can be placed inside an abstract class just like in java:",
24+
"code": "abstract class Soldier(val firstName: String, val lastName: String) {\n class Catch(val number: Long) {\n // nothing to do here. Just observe that it compiles\n }\n}\nclass Pilot(override val firstName: String, override val lastName: String,\n val squadron: Long) extends Soldier(firstName, lastName)\n\nval pilot = new Pilot(\"John\", \"Yossarian\", 256)\nval catchNo = new pilot.Catch(22) //using the pilot instance's path, create an catch object for it.\ncatchNo.number should be (__)",
2525
"solutions": [
26-
"22",
2726
"22"
2827
],
2928
"postparagraph": ""
3029
}
3130
]
32-
}
31+
}

0 commit comments

Comments
 (0)