Last active
February 5, 2021 09:23
-
-
Save dickygiancini/52a8e749472c5f86e0f6e3a9a3570d03 to your computer and use it in GitHub Desktop.
New Ablation. more class, method studies
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
void main() { | |
var student1 = Student(); | |
var dataId = student1.id = 1; | |
var dataName = student1.name = "Tom"; | |
print("The id is ${dataId} and the name is ${dataName}"); | |
print(""); | |
student1.study(); | |
student1.idNumb(); | |
print(""); | |
var student3 = NewStudent.myCustomConstructor(); | |
student3.id = 54; | |
student3.name = "Rahul"; | |
print("The id is ${student3.id} and the name is ${student3.name}"); | |
print(""); | |
student3.newidNumb(); | |
} | |
class Student { | |
int id = 0; | |
String name; | |
void study(){ | |
print("${this.name} is studying"); | |
} | |
void sleep(){ | |
print("${this.name} currently sleeping"); | |
} | |
void idNumb(){ | |
print("${this.id} is his/her id"); | |
} | |
} | |
class NewStudent { | |
int id = 0; | |
String name; | |
NewStudent(this.id, this.name); | |
NewStudent.myCustomConstructor() { // Named Constructor | |
print("This is a constructor"); | |
} | |
void newstudy(){ | |
print("${this.name} is studying"); | |
} | |
void newsleep(){ | |
print("${this.name} currently sleeping"); | |
} | |
void newidNumb(){ | |
print("${this.id} is ${this.name}'s id"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment