Created
February 25, 2024 23:33
-
-
Save Shuvo8693/14f9edda5691bbeeacb2a03fdc4fd57a to your computer and use it in GitHub Desktop.
student details with OOP(Constructor Method)
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() { | |
Student student = Student(); // here we can also provide values | |
student.sayHello(); | |
print(student.getRollSquared()); | |
student.getAddress(); | |
} | |
class Student{ | |
String name; | |
int roll; | |
String address; | |
Student({this.name='shuvo',this.roll=88,this.address='Uttarkhan'}); | |
void sayHello(){ | |
return print('Hello, My Name is $name'); | |
} | |
int getRollSquared(){ | |
return roll*roll; | |
} | |
void getAddress(){ | |
return print('My location is $address'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment