Dart
xxxxxxxxxx
abstract class Animal {
String name;
Animal(this.name);
String get noise;
}
class Dog extends Animal {
Dog(String name) : super(name);
String get noise => 'bark!';
}
class Pikachu implements Animal {
String name = 'Pikachu';
String get noise => 'pika!';
}
void releaseAnimals(Iterable animals) {
animals.forEach((a) => print('${a.name} has been released: ${a.noise}'));
}
main() {
var barry = new Dog('Barry');
var pika = new Pikachu();
releaseAnimals([barry, pika]);
}
$ dart inheritance.dart Barry has been released: bark! Pikachu has been released: pika!
C - Find Largest Number Using Dynamic Memory Allocation
Linux - How to Install anc-api-tools
Kotlin - Find Factorial of a Number
Java - Concatenate Two Arrays
Java - Reverse a Number
Python - How do I sort a dictionary by value?
JavaScript - Count the Number of Vowels in a String
Linux - How to Install zlib1g-dev
C++ - Check Whether a Number is Prime or Not
Java - Create Pyramid and Pattern
PHP - Associative Array in Ascending Order by Value
Linux - How to Install curvedns
Kotlin - Get Current Date/TIme
Kotlin - Check Whether a Number is Even or Odd
Kotlin - Calculate the Power of a Number
Kotlin - Multiply two Floating Point Numbers
Kotlin - Calculate the Sum of Natural Numbers
C++ - Convert Binary Number to Decimal and vice-versa
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month