Last active
May 6, 2019 12:32
-
-
Save izzuddin91/73a390f65ef14fa8094d7d39492a8f7a to your computer and use it in GitHub Desktop.
crops function2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated object oriented programming