Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
43
Task/Polymorphism/Wollok/polymorphism.wollok
Normal file
43
Task/Polymorphism/Wollok/polymorphism.wollok
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
class Point {
|
||||
var x
|
||||
var y
|
||||
new(ax, ay) {
|
||||
this.x = ax
|
||||
this.y = ay
|
||||
}
|
||||
new(point) {
|
||||
this(point.x, point.y)
|
||||
}
|
||||
method getX() { return x }
|
||||
method setX(newX) { x = newX }
|
||||
|
||||
method getY() { return y }
|
||||
method setY(newY) { y = newY }
|
||||
|
||||
method print() {
|
||||
console.println("Point")
|
||||
}
|
||||
}
|
||||
|
||||
class Circle extends Point {
|
||||
var r
|
||||
|
||||
new() { this(0,0,0) }
|
||||
new(point, aR) { super(point) ; r = aR }
|
||||
new(aX, aY, aR) { super(aX, aY); r = aR }
|
||||
|
||||
method getR() { return r }
|
||||
method setR(newR) { r = newR }
|
||||
|
||||
method print() {
|
||||
console.println("Circle")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
program polymorphism {
|
||||
val p = new Point()
|
||||
val c = new Circle()
|
||||
p.print()
|
||||
c.print()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue