Я заканчиваю свою курсовую работу, простая библиотечная система.
Я сталкиваюсь с проблемой, как показано ниже:
book.rb
class Book
attr_accessor :title, :author, :language, :classification, :isbn, :book_id, :borrow_status
def initialize(title, author, language, classification, isbn, book_id, borrow_status)
@title = title
@author = author
@language = language
@classification = classification
@isbn = isbn
@book_id = book_id
@borrow_status = borrow_status
end
def bookid
@book_id
end
def booklist
@title = @title.split(/ |\_|\-/).map(&:capitalize).join(" ")
@author = @author.split(/ |\_|\-/).map(&:capitalize).join(" ")
@language = @language.capitalize!
@isbn.to_s
@book_id.to_s
{
"Title" => @title,
"Author" => @author,
"Language" => @language,
"Classification" => @classification,
"ISBN" => @isbn,
"Book ID" => @book_id,
"Status" => @borrow_status,
}
end
end
user.rb
require_relative 'book.rb'
class User
attr_accessor :name, :address, :gender, :age, :id, :borrow
def initialize(name, address, gender, age, id, borrow)
@name = name
@address = address
@gender = gender
@age = age
@id = id
@borrow = borrow
end
def userlist
@name = @name.split(/ |\_|\-/).map(&:capitalize).join(" ")
@address = @address.split(/ |\_|\-/).map(&:capitalize).join(" ")
@age.to_s
@id.to_s
if @borrow.nil?
puts "nothing"
elsif
puts #I wish I can put book's name here, if I entered correct @borrow. eg.,for user3's @borrow=4(in top.rb), user3.@borrow=book4.@book_id, then print @name of book4
else
puts "error"
end
проблема внутри user.rb, в цикле if-elsif-else, который
Я бы хотелможете ввести название книги здесь, если я правильно ввел @borrow.например, для @ заем = 4 пользователя (в top.rb), пользователя 3. @ заем = book4. @ book_id, а затем выведите @name книги4
любое решение?