Skip to content

Instantly share code, notes, and snippets.

@mosleim
Created September 29, 2022 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mosleim/d079051a38443e942160fd4a28a642da to your computer and use it in GitHub Desktop.
Save mosleim/d079051a38443e942160fd4a28a642da to your computer and use it in GitHub Desktop.
quaint-dawn-1244
// 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