Skip to content

Commit

Permalink
Interface in Dart
Browse files Browse the repository at this point in the history
  • Loading branch information
smartherd committed Jul 3, 2018
1 parent f1c549d commit 1af0dd8
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions 26_interface.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

// Objectives
// 1. Interface

void main() {

var tv = Television();
tv.volumeUp();
tv.volumeDown();
}

class Remote {

void volumeUp() {
print("______Volume Up from Remote_______");
}

void volumeDown() {
print("______Volume Down from Remote_______");
}
}

class AnotherClass {

void justAnotherMethod(){
// Code
}

}

// Here Remote and AnotherClass acts as Interface
class Television implements Remote, AnotherClass {

void volumeUp() {
// super.volumeUp(); // Not allowed to call super while implementing a class as Interface
print("______Volume Up in Television_______");
}

void volumeDown() {
print("______Volume Down in Television_______");
}

void justAnotherMethod() {
print("Some code");
}
}

0 comments on commit 1af0dd8

Please sign in to comment.