Created
October 16, 2023 02:35
-
-
Save abdorll/09c1a724c05778e575b173a5a1c855e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//============Syntax | |
class ParentClassOrSuperClass { | |
// Parent class properties and methods | |
} | |
class ChildClassOrSubClass extends ParentClassOrSuperClass { | |
// Child class properties and methods | |
} | |
// =================Parent class | |
// =================Parent class | |
// =================Parent class | |
class Person { | |
// Properties | |
String? name; | |
int? age; | |
// Method | |
void display() { | |
print("Name: $name"); | |
print("Age: $age"); | |
} | |
} | |
// =================Child class extending the Parent class | |
// =================Child class extending the Parent class | |
// =================Child class extending the Parent class | |
class Student extends Person { | |
// Fields | |
String? schoolName; | |
String? schoolAddress; | |
// Method | |
void displaySchoolInfo() { | |
print("School Name: $schoolName"); | |
print("School Address: $schoolAddress"); | |
} | |
} | |
void main() { | |
// Creating an object of the Student class | |
var student = Student(); | |
student.name = "John"; | |
student.age = 20; | |
student.schoolName = "University of Lagos"; | |
student.schoolAddress = "University Road"; | |
student.display(); | |
student.displaySchoolInfo(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment