So i need some support with my Ruby assignment, I'm not from US so you have to excuse my English.
We are building a hotel and this is the second assignment. It's a console based application and I have a class called main.rb that handles the runtime and a guest-class.
In this second assignment we are to preload the app with five guest-objects, I guess I have to use an array but don't really know how. Below are my guest class and my main class is simply a while-loop with a case statement.
I need help with: 1. adding 5 guests (not to a db or textfile only to a array or so) when the program starts 2. the hotel has 20 rooms and i need to randomize the room number and exclude already rented rooms
// Hope you can help Thanks
class Guest
#Instance variables.
attr_accessor :firstName,
:lastName,
:address,
:phone,
:arrival,
:plot,
:gauge
#Constructor sets the guest details.
def initialize(first, last, adress, phone, arrival)
@firstName = first
@lastName = last
@address = address
@phone = phone
@arrival = arrival
@plot = range_rand(1,32)
@gauge = range_rand(2000,4000)
end
#Using rand()-method to randomize a value between min and max parameters.
def range_rand(min,max)
min + rand(max-min)
end
def to_string
"Name = #{@firstName} , Plot = #{@plot}"
end
end