28 lines
605 B
Dart
Raw Normal View History

2024-10-22 08:55:54 +04:00
class Student {
String name;
int age;
List<String> courses;
final String? image;
2024-12-12 13:40:51 +04:00
final String? id;
2024-10-22 08:55:54 +04:00
2024-12-12 13:40:51 +04:00
Student(this.name, this.age, this.courses, {this.image, this.id});
2024-10-22 08:55:54 +04:00
static String getYearWord(int age) {
2024-12-08 18:49:37 +04:00
if (age == -1) {
2024-10-22 08:55:54 +04:00
return "Undefined";
}
if (age % 10 == 1) {
return age.toString() + " год";
} else if (age % 10 < 5 && age % 10 != 0) {
return age.toString() + " года";
} else {
return age.toString() + " лет";
}
}
void displayInfo() {
print('Name: $name, Age: $age');
print('Courses: ${courses.join(", ")}');
}
}