Я создал небольшую бухгалтерскую программу, основанную на некоторых онлайн-уроках, но программа, похоже, не работает. Я довольно новичок в Ruby, но я получу любую помощь и советы, которые я могу получить! Спасибо заранее!Ruby - Проблемы с учетной записью
class Account
attr_reader :name, :check_account, :save_account
def initialize(name, check_account, save_account)
@name = name
@check_account = check_account
@save_account = save_account
end
def display_balance(pin_number)
puts "Enter pin please\n"
input = gets.chomp
if input == pin
main_menu
else
pin_error
end
end
def main_menu
puts "Welcome back #{name}!\n
What would you like to do?\n
Display balance (1)\n
Make a withdraw (2)\n
Make a deposit (3)\n
Quit (4)\n"
input = gets.chomp
case option
when 1
balance
when 2
withdraw
when 3
deposit
else
exit
end
end
def balance
puts "Which account do you wish to access? Checking or Savings?\n"
input = gets.chomp
if input =~ /checking/i
puts "Checking Balance: $#{check_account}."
else if input =~ /savings/i
puts "Savings Balance: $#{save_account}."
else
main_menu
end
end
end
def withdraw(pin_number, amount)
puts "Enter your PIN please\n"
input - gets.chomp
case withdraw
when check_account
@check_account -= amount
puts "You withdrew $#{amount} and now have $#{check_account} in your Checking."
when save_account
@save_account -= amount
puts "You withdrew $#{amount} and now have $#{save_account} in your Savings."
else
pin_error
end
end
def deposit
puts "What account do you want to deposit into? Checking or Savings?"
input = gets.chomp
if input =~ /checking/i
@check_account += amount
puts "You deposited $#{amount} adding up to a total of $#{check_account} in your Checking."
else if input =~ /savings/i
@save_account += amount
puts "You deposited $#{amount} adding up to a total of $#{save_account} in your Savings."
else
main_menu
end
end
end
private
def pin
@pin =1234
end
def pin_error
"Access denied: incorrect PIN."
end
def amount_error
"Access denied: incorrect amount."
end
end
my_account = Account.new("Andrew", 100_000, 250_000)
my_account.display
У вас, похоже, отсутствует вопрос в вашем вопросе. – Amadan