5 making a withdrawal


#1

class Account
attr_reader :name
attr_reader :balance
def initialize(name,balance=100)
@name= name
@balance= balance
end
private
def pin
@pin=1234
end
private
def pin_error
return "Access denied: incorrect PIN."
end
public
def display_balance(pin_number)
if pin_number==pin
puts "Balance: $#{@balance}"
else puts pin_error
end
def withdraw(pin_number, amount)
if pin_number == pin
@balance -= amount
puts "Withdrew #{amount}. New balance: $#{@balance}."
else
puts pin_error
end
end
i def the method withdraw perfectly but it still wont work. i even pasted the method from the original lesson and still nothing. please tell me what happened


#2

@arrayace23705,
You are missing an =end= to close your class Account definition
You are missing an =end= to close your_withdraw_ function


#3

class Account
attr_reader :name, :balance
def initialize(name, balance=100)
@name = name
@balance = balance
end

def display_balance(pin_number)
puts pin_number == pin ? "Balance: $#{@balance}." : pin_error
end

def withdraw(pin_number, amount)
if pin_number == pin
@balance -= amount
puts "Withdrew #{amount}. New balance: $#{@balance}."
else
puts pin_error
end
end

private

def pin
@pin = 1234
end

def pin_error
"Access denied: incorrect PIN."
end
end