generated from microverseinc/readme-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_instance.rb
47 lines (44 loc) · 1.03 KB
/
create_instance.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require_relative './student'
require_relative './teacher'
require_relative './book'
class Create
def create_student
id = Random.rand(1...100)
print 'Age: '
age = gets.chomp
print 'Name: '
name = gets.chomp
print 'Has Parent Permission? [Y/N]: '
permission = gets.chomp.upcase
case permission
when 'Y'
permission = true
when 'N'
permission = false
end
student = Student.new(id, age, nil, name, parent_permission: permission)
puts 'Student created successfully'
student
end
def create_teacher
id = Random.rand(1...100)
print 'Age: '
age = gets.chomp
print 'Name: '
name = gets.chomp
print 'Specialization '
specialization = gets.chomp
teacher = Teacher.new(id, age, specialization, name)
puts 'Teacher created successfully'
teacher
end
def create_book
print 'Title: '
title = gets.chomp
print 'Author: '
author = gets.chomp
book = Book.new(title, author)
puts 'Book created successfully'
book
end
end