Skip to content

Commit

Permalink
Abstract Class and Methods. With Inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
smartherd committed Jul 3, 2018
1 parent 8b3f036 commit f1c549d
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions 25_abstract_class_method.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

// Objectives
// 1. Abstract Method
// 2. Abstract Class

void main() {

// var shape = Shape(); // Error. Cannot instantiate Abstract Class

var rectangle = Rectangle();
rectangle.draw();

var circle = Circle();
circle.draw();
}

abstract class Shape {

// Define your Instance variable if needed
int x;
int y;

void draw(); // Abstract Method

void myNormalFunction() {
// Some code
}
}


class Rectangle extends Shape {

void draw() {
print("Drawing Rectangle.....");
}
}

class Circle extends Shape {

void draw() {
print("Drawing Circle.....");
}
}

0 comments on commit f1c549d

Please sign in to comment.