Skip to content

Instantly share code, notes, and snippets.

@abdorll
Created October 16, 2023 00:11
Show Gist options
  • Save abdorll/aca7afa13836a2eedfb7958908fc0235 to your computer and use it in GitHub Desktop.
Save abdorll/aca7afa13836a2eedfb7958908fc0235 to your computer and use it in GitHub Desktop.
// ========= SYNTAX
class ClassName {
// properties or attributes...
//...
// methods or functions...
}
//======== EXAMPLE
//======== EXAMPLE
//======== EXAMPLE
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;
}
// Methods 2: updateGPA
void updateGPA(double newGpa) {
gpa = newGpa;
}
// Methods 3: printBioData
void printBioData() {
print("Name: $name");
print("Matric Number: $matricNumber");
print("Age: $age");
print("Department: $department");
print("GPA: $gpa");
}
}
void main(){}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment