Skip to content

Instantly share code, notes, and snippets.

View abdorll's full-sized avatar
🧑‍💻
Coding...

Abdullah Opadeji abdorll

🧑‍💻
Coding...
View GitHub Profile
void main() {
//abstract class
}
void main() {
//enums
}
void main() {
//static
}
void main() {
//polymorphism
}
//============Syntax
class ParentClassOrSuperClass {
// Parent class properties and methods
}
class ChildClassOrSubClass extends ParentClassOrSuperClass {
// Child class properties and methods
}
// =================Parent class
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
// 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;
}
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;
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;
// ========= SYNTAX
class ClassName {
// properties or attributes...
//...
// methods or functions...
}
//======== EXAMPLE
//======== EXAMPLE