feat: add to_s method in Student class for formatted output and create main.rb to instantiate and display Student objects

main
Artem-Darius Weber 4 months ago
parent 57a51641e7
commit 835a6b7738

@ -0,0 +1,22 @@
require_relative 'student'
student1 = Student.new(
surname: 'Алексеевич',
name: 'Артем-Дариус',
patronymic: 'Вебер',
id: 1,
phone: '+79891242223',
telegram: '@alstroemeria22',
email: 'no-replay@djft.ru',
git: 'https://git.djft.ru'
)
student2 = Student.new(
surname: 'nil',
name: 'Норакет',
patronymic: 'nil'
)
puts student1
puts '-' * 40
puts student2

@ -11,4 +11,13 @@ class Student
@email = email
@git = git
end
def to_s
"Student: #{@surname} #{@name} #{@patronymic}\n" \
"ID: #{@id || 'N/A'}\n" \
"Phone: #{@phone || 'N/A'}\n" \
"Telegram: #{@telegram || 'N/A'}\n" \
"Email: #{@email || 'N/A'}\n" \
"Git: #{@git || 'N/A'}"
end
end
Loading…
Cancel
Save