Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
44
Task/Abstract-type/Haxe/abstract-type-1.hx
Normal file
44
Task/Abstract-type/Haxe/abstract-type-1.hx
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
interface Vocal {
|
||||
public function speak():String;
|
||||
}
|
||||
|
||||
interface Gravitational {
|
||||
public function getWeight():Int;
|
||||
}
|
||||
|
||||
abstract class Dog implements Vocal implements Gravitational {
|
||||
public function speak():String {
|
||||
return "Woof";
|
||||
}
|
||||
|
||||
public function new() {}
|
||||
}
|
||||
|
||||
class Chihuahua extends Dog {
|
||||
public function getWeight():Int {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
|
||||
class GreatDane extends Dog {
|
||||
public function getWeight():Int {
|
||||
return 150;
|
||||
}
|
||||
}
|
||||
|
||||
class Main {
|
||||
static public function main():Void {
|
||||
var dogs:Array<Dog> = [];
|
||||
|
||||
var david = new Chihuahua();
|
||||
var goliath = new GreatDane();
|
||||
|
||||
dogs.push(david);
|
||||
dogs.push(goliath);
|
||||
|
||||
for (dog in dogs) {
|
||||
trace(dog.speak());
|
||||
trace(dog.getWeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Task/Abstract-type/Haxe/abstract-type-2.hx
Normal file
3
Task/Abstract-type/Haxe/abstract-type-2.hx
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
class abstraction()
|
||||
abstract method compare(l,r) # generates runerr(700, "method compare()")
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue