This file contains 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
void main() { | |
//abstract class | |
} |
This file contains 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
void main() { | |
//enums | |
} |
This file contains 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
void main() { | |
//static | |
} |
This file contains 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
void main() { | |
//polymorphism | |
} |
This file contains 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 |
This file contains 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
class Book { | |
// Private Properties | |
String? _title; | |
String? _author; | |
double? _price; | |
// Getter to read the private property _title | |
String get title => this._title!; | |
// Setter to update the private property _title |
This file contains 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
// WITHIN A SINGLE FILE, IT WON'T WORK | |
class Employee { | |
// Private property | |
var _name; | |
// Getter method to access private property _name | |
String getName() { | |
return _name; | |
} |
This file contains 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
class Employee { | |
String? name; | |
int? age; | |
String? department; | |
double? salary; | |
// Constructor | |
Employee(String name, int age, String department, double salary) { | |
this.name = name; | |
this.age = age; |
This file contains 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
class Student { | |
// ========== Properties (Attributes of a stident) | |
String? name, department; | |
int? age, matricNumber; | |
double? gpa; | |
// ========== Methods (Actions a student can do) | |
// Methods 1: switchDepartment | |
void switchDepartment(String newDepartment) { | |
department = newDepartment; |
This file contains 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 ClassName { | |
// properties or attributes... | |
//... | |
// methods or functions... | |
} | |
//======== EXAMPLE | |
//======== EXAMPLE |
NewerOlder