Last active
March 24, 2019 20:23
Revisions
-
AAQ-AND-DEV revised this gist
Mar 24, 2019 . 1 changed file with 41 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,20 +1,45 @@ //dart does not do interfaces, but rather all classes //seem to be able to be implemented abstract class IsFerocious { void intimidate(); String whatTheFearfulSay(); } class Animal{ String name; String lastName; String color; int weight; Animal(){} Animal.create(this.name){} Animal.fromInfo(this.name, this.lastName, this.color, this.weight){} String sayHello(){ return 'grunt'; } } class Cat extends Animal implements IsFerocious{ Cat.create(String name): super.create(name){ print(".create ctor used"); } Cat.fromInfo(String name, String lastName, String color, int weight) : super.fromInfo(name, lastName, color, weight); @override String sayHello() { return 'meow'; } @override void intimidate(){ print("${this.name} hisses"); } @override String whatTheFearfulSay(){ print("oh no! the cat is hissing. I'm so scared"); } } void main(){ @@ -32,6 +57,11 @@ void main(){ print(yourAge(name, lastName, 47)); print(yourAge(name, lastName)); var willie = new Cat.fromInfo(name, lastName, "black", 5); print("${willie.name} says ${willie.sayHello()}"); var jeo = new Cat.create("jeordie"); print("${jeo.name} says ${jeo.sayHello()}"); willie.intimidate(); willie.whatTheFearfulSay(); } -
AAQ-AND-DEV created this gist
Mar 24, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ class Cat{ String name; String lastName; String color; int kind; Cat(){} Cat.fromInfo(String name, String lastName, String color, int kind){ this.name = name; this.lastName = lastName; this.color = color; this.kind = kind; } String meow(){ return 'meow'; } } void main(){ var name = "willis"; var lastName = "busterino"; String yourAge(String name, String last, [int age]){ var res = "$name $last"; if (age != null){ res += " is $age"; } return res; } print(yourAge(name, lastName, 47)); print(yourAge(name, lastName)); var willie = new Cat.fromInfo(name, lastName, "black", 1); print("${willie.name} says ${willie.meow()}"); }