class Ivan{
String? name;
int? age;
}
class Aprivate{
String? name, surename;
int? _age;
void set age(int years) {
if(years > 0 && years < 120) {
_age = years;
}else {
_age = 0;
}
}
int get age {
return _age!; // to return null adding ! at the end
}
}
void main() {
Aprivate another = Aprivate();
another.name = 'Lert Ivan';
another.surename = 'Ivan Boginski';
another.age = 22;
print('name: ${another.name} \n surename: ${another.surename} \n age: ${another.age}');
Ivan tel = Ivan();
tel.name = 'Ivan Boginski';
tel.age = 27;
print('Name: ${tel.name}\n Age: ${tel.age}');
String myString = 'Throw your Dart';
String result = reverse(myString);
print(result);
String mySongs = anohterSing();
print(mySongs);
}
String reverse(String young) {
int length = young.length;
String res = '';
// String? res;
for (int i = length-1; i >= 0; i--) {
res += young.substring(i,i + 1);
}
return res;
}
// String sing() {
// var songs = <String>[];
// var songString = '';
// // var String? songString;
// songs.add('I think is better');
// songs.add('This');
// songs.add('Nothing bad');
// int i = 0;
// // while ( i < songs.length) {
// // songString += '${songs[i]} - ';
// songs.forEach((song) => songString += song + " - ");
// i++;
// }
// return songString;
// }
String anohterSing() {
var songs = <String>[];
songs.add('Nothing Crazy');
songs.add('Yeah');
songs.add('There is yours');
var capitalSongs = songs.map((song) => song.toUpperCase());
return capitalSongs.toString();
}
No comments:
Post a Comment