diff --git a/lab2/README.md b/lab2/README.md index b92539b..5c0360d 100644 --- a/lab2/README.md +++ b/lab2/README.md @@ -49,9 +49,9 @@ classDiagram } class StudentShort { - - surname_initials : String - + get_surname_initials() : String - + StudentShort(id : String, surname_initials : String, phone: String, telegram: String, email: String) + - name_initials : String + + get_name_initials() : String + + StudentShort(id : String, name_initials : String, phone: String, telegram: String, email: String) + from_student(student : Student) : StudentShort <> + from_string(id : String, info_string : String) : StudentShort <> + to_s() : String diff --git a/lab2/student_short.rb b/lab2/student_short.rb index 80bc23a..ea5d884 100644 --- a/lab2/student_short.rb +++ b/lab2/student_short.rb @@ -1,18 +1,18 @@ require_relative 'person' class StudentShort < Person - attr_reader :surname_initials + attr_reader :name_initials - def initialize(id:, surname_initials:, phone: nil, telegram: nil, email: nil) + def initialize(id:, name_initials:, phone: nil, telegram: nil, email: nil) super(id: id, phone: phone, telegram: telegram, email: email) - @surname_initials = surname_initials + @name_initials = name_initials freeze end def self.from_student(student) new( id: student.id, - surname_initials: student.surname_and_initials, + name_initials: student.surname_and_initials, phone: student.phone, telegram: student.telegram, email: student.email @@ -23,14 +23,14 @@ class StudentShort < Person parts = info_string.split(',').map(&:strip) raise ArgumentError, 'Invalid info string format' if parts.size < 2 - surname_initials = parts[0] + name_initials = parts[0] contact_string = parts[1].split(': ', 2).last.strip phone, telegram, email = parse_contact_string(contact_string) new( id: id, - surname_initials: surname_initials, + name_initials: name_initials, phone: phone, telegram: telegram, email: email @@ -39,7 +39,7 @@ class StudentShort < Person def to_s contact_info = get_first_contact() - "#{@surname_initials}, Contact: #{contact_info}" + "#{@name_initials}, Contact: #{contact_info}" end private