Advertisement
Guest User

test

a guest
Mar 3rd, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. -- The Account table.
  2. Account = {balance = 0}
  3.  
  4. -- The withdraw function.
  5. function Account.withdraw(self,v)
  6.   self.balance = self.balance - v
  7. end
  8.  
  9. -- Print the first balance of both accounts.
  10. print(" ------------ First Check -------------")
  11. print("     Jasper's Balance: "..Jasper.balance)
  12. print("     Gerry's Balance: "..Gerry.balance)
  13. print(" --------------------------------------")
  14.  
  15. -- Take 20 of Jasper's balance, 2000000 of Gerry's balance
  16. Account.withdraw(Jasper, 20)
  17. Account.withdraw(Gerry, 2000000)
  18.  
  19. -- Print the second balance of both accounts.
  20. print(" ------------ Second Check ------------")
  21. print("     Jasper's Balance: "..Jasper.balance)
  22. print("     Gerry's Balance: "..Gerry.balance)
  23. print(" --------------------------------------")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement