Created with <3 with dartpad.dev.
Created
September 29, 2022 06:34
-
-
Save mosleim/d079051a38443e942160fd4a28a642da to your computer and use it in GitHub Desktop.
quaint-dawn-1244
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 characters
// properti | |
// behavior | |
class Person{ | |
String name; | |
int age; | |
Person(this.name, this.age); | |
String getMessage(){ | |
final msg ="$name age is $age"; | |
return msg; | |
} | |
hello(){ | |
print(name); | |
} | |
} | |
class Singer extends Person { | |
Singer(String name, int age):super(name, age); | |
singing(){ | |
print("$name are singing"); | |
} | |
} | |
void main() { | |
var bashori = Person("Bashori", 10); | |
var hasan = Person("Hasan", 11); | |
var tio = Person("Tio", 12); | |
var afgan = Singer("Afganistany", 40); | |
List<Person> someones = [hasan, bashori , tio, afgan ]; | |
for(var one in someones){ | |
final message = one.getMessage(); | |
print(message); | |
} | |
} | |
// method itu adalah function atau behavior | |
// class itu adalah tipe data custom | |
// class punya property dan behavior | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment