Skip to content

Instantly share code, notes, and snippets.

@BrayanZ
Last active December 16, 2015 23:49
Show Gist options
  • Save BrayanZ/5516550 to your computer and use it in GitHub Desktop.
Save BrayanZ/5516550 to your computer and use it in GitHub Desktop.
class Example
def initialize(headquarters, positions)
@positions = positions
@headquarters = headquarters
end
def open_headquarter(headquarter)
@headquarters[headquarter] = []
end
def close_headquarter(headquarter)
@headquarters.delete(headquarter)
end
def add_position_to_headquarter(headquarter, position)
@headquarters[headquarter] << position
end
def hire_employee(headquarter, position_name, employee)
position = @headquarters[headquarter].find{|position| position[:name] == position_name}
position[:employees] << employee
end
def chage_position_base_salary(position_name, new_base_salary)
position = @positions.find{|position| position[:name] == position_name}
position[:base_salary] = new_base_salary
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment