Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ATM
- def start(config)
- customer = Customer.new("","","","")
- customer.account = customer.get_account
- if customer.existing_account?(config,customer.account)
- customer.password = customer.get_password
- if customer.verified_password?(config,customer.account,customer.password)
- customer.name = customer.get_name(config,customer.account)
- customer.balance = customer.get_balance(config,customer.account)
- puts "Hello, #{customer.name}!"
- #menu(config,account,customer)
- else puts "ERROR: ACCOUNT NUMBER AND PASSWORD DON'T MATCH"
- start(config)
- end
- else puts "ERROR: ACCOUNT NUMBER NOT FOUND"
- start(config)
- end
- end
- end
- class Customer
- attr_accessor :account, :password, :name, :balance
- def initialize(account,password,name,balance)
- @accont = account
- @password = password
- @name = name
- @balance = balance
- end
- def get_account
- print "Please Enter Your Account Number: "
- acc = gets
- account = acc.to_i
- end
- def existing_account?(config,account)
- return true if config['accounts'].has_key?(account)
- false
- end
- def get_password
- print "Please Enter Your Password: "
- pass = gets
- pasword = pass.chomp
- end
- def verified_password?(config,account,password)
- return true if config['accounts'][account]['password'] == password
- false
- end
- def get_name(config,account)
- name = config['accounts'][account]['name']
- end
- def get_balance(config,account)
- balance = config['accounts'][account]['balance']
- end
- end
- config = {"banknotes"=>{500=>0, 200=>0, 100=>2, 50=>1, 20=>2, 10=>4, 5=>1, 2=>0, 1=>2}, "accounts"=>{3321=>{"name"=>"Volodymyr", "password"=>"mypass", "balance"=>422}, 5922=>{"name"=>"Iryna", "password"=>"1111", "balance"=>5301}}}
- atm = ATM.new
- atm.start(config)
Add Comment
Please, Sign In to add comment