Skip to content

Instantly share code, notes, and snippets.

@fakefarm
Created April 17, 2012 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fakefarm/2406501 to your computer and use it in GitHub Desktop.
Save fakefarm/2406501 to your computer and use it in GitHub Desktop.
Code Academy Class 3
class Animal
def name=(nick_name)
@name = nick_name
end
def name
return @name
end
def noise=(input)
@noise=input
end
def noise
return @noise
end
end
cow = Animal.new
cow.name = "Bessie"
puts "What sound does a cow make?"
cow.noise = gets.chomp
puts "Yeah, but an angry cow says #{cow.noise.upcase}!!"
puts "Now get out of here before I have #{cow.name} chase you off my property!"
class Account
def initialize
puts "You have a new account with us!"
@balance = 0
end
def deposit(value)
@balance += value
end
def balance
return @balance
end
end
checking = Account.new
puts "Your current balance is #{checking.balance}"
puts "Would you like make a deposit?"
cust_response = gets.chomp.downcase
if cust_response =="no"
puts "Have a nice day!"
else
until cust_response == "no"
puts "How much would you like to deposit?"
value=gets.chomp.to_i
checking.deposit(value)
puts "Your new balance is #{checking.balance}"
puts ""
puts "Would you like make a deposit?"
cust_response = gets.chomp.downcase
end
puts "Have a nice day!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment