Skip to content

Instantly share code, notes, and snippets.

@izzuddin91
Last active May 6, 2019 12:32
Show Gist options
  • Save izzuddin91/73a390f65ef14fa8094d7d39492a8f7a to your computer and use it in GitHub Desktop.
Save izzuddin91/73a390f65ef14fa8094d7d39492a8f7a to your computer and use it in GitHub Desktop.
crops function2
class Crops
attr_accessor :sam #declare a variable named sam here
attr_accessor :luke #declare a variable named luke here
def initialize()
@sam = ["apple", "carrot"] #declare that sam has what
@luke = ["carrot"] #declare that luke has what
end
def instruction
return "Please select person"
end
def process_input(input)
if input == "sam"
return self.sam
elsif input == "luke"
return self.luke
end
end
end
crops = Crops.new # <- will call the initialize method , line 6
instruction = crops.instruction
puts "#{instruction}"
a = gets.chomp
b = crops.process_input(a)
puts "#{a} has #{b}"
@izzuddin91
Copy link
Author

updated object oriented programming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment