Issues calling method from another class

Hello,

I’m a newbie and having some issues calling a method from another
class. I keep getting an error saying undefined method. The method I’m
trying to call is in the employees.rb file and I’m trying to run it in
my business.rb file. Its option 2 in my case statement.

Keith Bachand wrote in post #1182881:

Hello,

I’m a newbie and having some issues calling a method from another
class. I keep getting an error saying undefined method. The method I’m
trying to call is in the employees.rb file and I’m trying to run it in
my business.rb file. Its option 2 in my case statement.

in business.rb, you have :
when 2
new_employee(name)

new_employee() is a method member of class Employees.
if you want call him out of instance; declare it
as static methode:

def self.new_employee()
puts “What is the employees name?”
name = gets.chomp
e1 = Employees.new(name)
end

So you cal call
emp=Employees.new_employee()

Thank you so much! Idk why I didn’t try it that way!