Created
October 16, 2023 00:11
-
-
Save abdorll/aca7afa13836a2eedfb7958908fc0235 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 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