PIbd-32_Stroev_V_M_PMD/lib/domain/models/Student.dart

32 lines
595 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;
Student(
this.name,
this.age,
this.courses, {
this.image
});
static String getYearWord(int age) {
if(age == -1){
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(", ")}');
}
}