|
|
|
# Lab 2
|
|
|
|
|
|
|
|
|
|
|
|
## Диаграмма классов:
|
|
|
|
|
|
|
|
```mermaid
|
|
|
|
classDiagram
|
|
|
|
class BinarySearchTree {
|
|
|
|
- root : Node
|
|
|
|
+ add(student : Student) : void
|
|
|
|
+ each(&block) : void
|
|
|
|
- insert(node : Node, student : Student) : Node
|
|
|
|
- in_order_traversal(node : Node, &block) : void
|
|
|
|
}
|
|
|
|
|
|
|
|
class Node {
|
|
|
|
- student : Student
|
|
|
|
- left : Node
|
|
|
|
- right : Node
|
|
|
|
+ Node(student : Student)
|
|
|
|
}
|
|
|
|
|
|
|
|
class Contact {
|
|
|
|
- phone : String?
|
|
|
|
- telegram : String?
|
|
|
|
- email : String?
|
|
|
|
+ Contact(phone : String?, telegram : String?, email : String?)
|
|
|
|
+ present() : Boolean
|
|
|
|
+ get_single_contact() : String
|
|
|
|
+ phone=(String) : Boolean
|
|
|
|
+ telegram=(String) : Boolean
|
|
|
|
+ email=(String) : Boolean
|
|
|
|
+ self.valid_phone_number() : Boolean
|
|
|
|
+ self.valid_telegram() : Boolean
|
|
|
|
+ self.valid_email() : Boolean
|
|
|
|
+ new_from_info(info_string : String) : Contact
|
|
|
|
}
|
|
|
|
|
|
|
|
class Person {
|
|
|
|
- id : String
|
|
|
|
- git : String
|
|
|
|
- contact : Contact
|
|
|
|
+ Person(id : String, git : String, contact : Contact)
|
|
|
|
+ git_present() : Boolean
|
|
|
|
+ contact_present() : Boolean
|
|
|
|
+ contact_info() : String
|
|
|
|
+ git=(String) : Boolean
|
|
|
|
- validate_id(id: String) : Boolean
|
|
|
|
- validate_git(id: String) : Boolean
|
|
|
|
|
|
|
|
- valid_git(git : String) : Boolean
|
|
|
|
- valid_id(id : String) : Boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
class StudentRepository {
|
|
|
|
+ read_from_txt(file_path : String) : List~Student~
|
|
|
|
+ write_to_txt(file_path : String, students : List~Student~)
|
|
|
|
}
|
|
|
|
|
|
|
|
class StudentShort {
|
|
|
|
- surname_initials : String
|
|
|
|
- contact : Contact
|
|
|
|
+ StudentShort(id : String, git : String, surname_initials : String, contact : Contact)
|
|
|
|
+ from_student(student : Student) : StudentShort
|
|
|
|
+ from_string(id : String, info_string : String) : StudentShort
|
|
|
|
+ to_s() : String
|
|
|
|
}
|
|
|
|
|
|
|
|
class Student {
|
|
|
|
- surname : String
|
|
|
|
- name : String
|
|
|
|
- patronymic : String
|
|
|
|
- birth_date : Date
|
|
|
|
+ Student(id : String, git : String, contact : Contact, surname : String, name : String, patronymic : String, birth_date : Date)
|
|
|
|
+ from_string(student_string : String) : Student
|
|
|
|
+ surname_and_initials() : String
|
|
|
|
+ to_s() : String
|
|
|
|
+ get_info() : String
|
|
|
|
- validate_student()
|
|
|
|
}
|
|
|
|
|
|
|
|
BinarySearchTree o-- Node
|
|
|
|
Node o-- Student
|
|
|
|
Contact <|-- Person
|
|
|
|
Person <|-- Student
|
|
|
|
Person <|-- StudentShort
|
|
|
|
Student <.. StudentRepository
|
|
|
|
```
|
|
|
|
|