diff --git a/.vscode/student.dart b/.vscode/student.dart deleted file mode 100644 index 6ae40e1..0000000 --- a/.vscode/student.dart +++ /dev/null @@ -1,36 +0,0 @@ -//parent class -class Teacher { - String name = ''; - String position = ''; - int age = 0; - - Teacher(String name, String position, int age) { - this.name = name; - this.age = age; - this.position = position; - - void display() { - print( - 'Name of teacher is $name , position is $position and his age is $age'); - } - } -} - -//child class -//TODO1 : declare the class -class Student extends Teacher { -//TODO2: DECLARE THE PROPERTIES - -//TODO3: DECLARE THE CONSTRUCTOR - Student(String name, String position, int age) : super(name, position, age) {} -//TODO 4: DECLARE THE METHODS - @override - void display() { - print('Name of student is $name and his age is $age'); - } -} - -void main() { - Student s1 = Student('binod', 'head', 23); - s1.display(); -} diff --git a/student.dart b/student.dart new file mode 100644 index 0000000..6a7792f --- /dev/null +++ b/student.dart @@ -0,0 +1,32 @@ +//parent class or super class +class Teacher { + String name; + String position; + int age; + + Teacher({ + this.name = '', + this.position = '', + this.age = 0, + }); + + void display() { + print( + 'Name of teacher is $name , position is $position and his age is $age'); + } +} + +//child class or base class + +class Student extends Teacher { + Student(String name, int age) : super(name: name, age: age) {} + + void display() { + print('Name of student is $name and his age is $age'); + } +} + +void main() { + Student s1 = Student('binod', 23); + s1.display(); +}