This enormous Dart program contains zero errors and warnings. This code has associated html and css.
Find this at dartpad.dartlang.org/?source=b833e9a2-7162-4a85-a7ed-90be32a9c91d.
Created with <3 with dartpad.dartlang.org.
This enormous Dart program contains zero errors and warnings. This code has associated html and css.
Find this at dartpad.dartlang.org/?source=b833e9a2-7162-4a85-a7ed-90be32a9c91d.
Created with <3 with dartpad.dartlang.org.
| class Color { | |
| String to_s() { | |
| if(this is Red){ | |
| return "#FF0000"; | |
| }else if(this is Green) { | |
| return "#00FF00"; | |
| }else if(this is Blue) { | |
| return "#0000FF"; | |
| }else if(this is Rgb) { | |
| return "rgb"; | |
| }else { | |
| throw new Error(); | |
| } | |
| } | |
| } | |
| class Red extends Color{} | |
| class Green extends Color{} | |
| class Blue extends Color{} | |
| class Rgb extends Color { | |
| num r; | |
| num g; | |
| num b; | |
| Rgb(this.r,this.g,this.b); | |
| } | |
| void main() { | |
| Color c = new Rgb(255,255,255); | |
| print(c.to_s()); | |
| } |