Last active
April 7, 2022 05:48
-
-
Save freedive-cebu30/c97ae48fa15b4572757109c5197d8cb1 to your computer and use it in GitHub Desktop.
class_12
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
class Person { | |
String? _name; | |
int? _age; | |
Person(String name, int age) { | |
_name = name; | |
_age = age; | |
} | |
void introduce() { | |
print(_name! + ':' + _age.toString()); | |
} | |
// ゲッター | |
String get name { | |
return _name!; | |
} | |
// セッター | |
set name(newName) { | |
_name = newName; | |
} | |
} | |
void main() { | |
Person jojo = Person('jojo', 30); | |
print(jojo.name); | |
// jojo | |
jojo.name = 'Duo'; | |
print(jojo.name); | |
// Duo | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment