Skip to content

Instantly share code, notes, and snippets.

@abdorll
Created October 16, 2023 02:35
Show Gist options
  • Save abdorll/09c1a724c05778e575b173a5a1c855e3 to your computer and use it in GitHub Desktop.
Save abdorll/09c1a724c05778e575b173a5a1c855e3 to your computer and use it in GitHub Desktop.
//============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