Skip to content

Instantly share code, notes, and snippets.

@jwo
Last active December 18, 2015 16:49
Show Gist options
  • Save jwo/5814432 to your computer and use it in GitHub Desktop.
Save jwo/5814432 to your computer and use it in GitHub Desktop.
The before picture. Your job, should you choose to accept it: make it better!
class User
def initialize(first_name, last_name)
@firstName = first_name
@lastName = last_name
end
def full_name
"#{@lastName} #{@firstName}"
end
def account
Account.for_user(self)
end
def isActive
if account.balance > 0
return true
else
return false
end
end
end
class Account
def self.for_user(user)
new
end
def balance
[50, 150, 2500].sample
end
end
def users
[
User.new("Frank", "Gleason"),
User.new("Bill", "Simmons"),
User.new("Sarah", "Coderson")
]
end
puts "----------User Account Balance Report ---------------------"
users.each do |user|
if user.isActive
puts user.full_name
puts user.account.balance
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment