Last active
March 11, 2019 22:08
-
-
Save AnielaMW/1b3862fa57574c1da93a3149f1c643a5 to your computer and use it in GitHub Desktop.
Pride and Prejudice Ruby Logic
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
puts "Pride and Prejudice Logic" | |
# It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife. | |
class Man | |
attr_reader :truth | |
def initialize (name, single, fortune) | |
@fortune = fortune | |
@single = single | |
@truth = "Mr. #{name} " + self.acknowledge | |
end | |
def acknowledge | |
@single && @fortune.include?("good") ? "want's a wife" : "does not want a wife." | |
end | |
end | |
men = [["Darcy", true, "good income"], | |
["Bingley", true, "good will toward all and a good income"], | |
["Collins", true, "good patroness"], | |
["Wickham", true, "good luck as a good liar"], | |
["Denny", true, "charming gentleman"], | |
["Bennet", false, "good humor"]] | |
men.each { |man| puts Man.new(man[0], man[1], man[2]).truth } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment