|
|
|
# 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 Person {
|
|
|
|
- id : String
|
|
|
|
- git : String
|
|
|
|
- phone : String?
|
|
|
|
- telegram : String?
|
|
|
|
- email : String?
|
|
|
|
+ Person(id : String, git : String, phone: String, telegram: String, email: String)
|
|
|
|
+ phone=(String) : Boolean
|
|
|
|
+ telegram=(String) : Boolean
|
|
|
|
+ email=(String) : Boolean
|
|
|
|
+ valid_phone_number() : Boolean <<class>>
|
|
|
|
+ valid_telegram() : Boolean <<class>>
|
|
|
|
+ valid_email() : Boolean <<class>>
|
|
|
|
+ git_present() : Boolean
|
|
|
|
+ contact_present() : Boolean
|
|
|
|
+ get_first_contact() : String
|
|
|
|
+ git=(git : String) : void
|
|
|
|
+ validate_id(id: String) : void <<class>>
|
|
|
|
+ validate_git(git : String) : void <<class>>
|
|
|
|
- valid_git?(git : String) : Boolean
|
|
|
|
- valid_id?(id : String) : Boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
class StudentRepository {
|
|
|
|
+ read_from_txt(file_path : String) : List~Student~ <<class>>
|
|
|
|
+ write_to_txt(file_path : String, students : List~Student~) <<class>>
|
|
|
|
}
|
|
|
|
|
|
|
|
class StudentShort {
|
|
|
|
- name_initials : String
|
|
|
|
+ get_name_initials() : String
|
|
|
|
+ StudentShort(id : String, name_initials : String, phone: String, telegram: String, email: String)
|
|
|
|
+ from_student(student : Student) : StudentShort <<class>>
|
|
|
|
+ from_string(id : String, info_string : String) : StudentShort <<class>>
|
|
|
|
+ to_s() : String
|
|
|
|
- parse_contact_string(contact_string: String) : Array<String> <<class>>
|
|
|
|
}
|
|
|
|
|
|
|
|
class Student {
|
|
|
|
- surname : String
|
|
|
|
- name : String
|
|
|
|
- patronymic : String
|
|
|
|
- birth_date : Date
|
|
|
|
- const NAME_REGEX : String
|
|
|
|
+ Student(id : String, git : String, phone: String, telegram: String, email: String, surname : String, name : String, patronymic : String, birth_date : Date)
|
|
|
|
+ from_string(student_string : String) : Student <<class>>
|
|
|
|
+ surname_and_initials() : String
|
|
|
|
+ to_s() : String
|
|
|
|
+ get_info() : String
|
|
|
|
+ surname=(surname : String)
|
|
|
|
+ name=(name : String)
|
|
|
|
+ patronymic=(patronymic : String)
|
|
|
|
+ birth_date=(birthdate : String)
|
|
|
|
+ valid_name?(name : String) : Boolean <<class>>
|
|
|
|
- name_initial(name : String) : String
|
|
|
|
- patronymic(patronymic : String) : String
|
|
|
|
}
|
|
|
|
|
|
|
|
BinarySearchTree o-- Node
|
|
|
|
Node o-- Student
|
|
|
|
Person <|-- Student
|
|
|
|
Person <|-- StudentShort
|
|
|
|
Student <.. StudentRepository
|
|
|
|
```
|
|
|
|
|