home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / armbob / armbob_1 / ARMBOB / !ArmBob / progs / h / account next >
Encoding:
Text File  |  1995-04-05  |  1.4 KB  |  73 lines

  1. /* Accounts    GCW    02/03/94  */
  2.  
  3. class account
  4. {
  5.  balance;        /* An account's state */
  6.  owner;
  7.  password;
  8.  starting_date;
  9.  
  10.  withdraw(x);   /* An account's methods */
  11.  statement();
  12.  change_password();
  13.  has_owner(name);
  14. }    
  15.  
  16. account::account(amount,name)
  17. {
  18.  balance = (amount>0)?amount:0;
  19.  owner = name;
  20.  print("Enter ",name,"'s password here: ");
  21.  password = hidden_input('-');
  22.  starting_date = sysvar("Sys$Date");
  23.  return this;
  24. }
  25.  
  26. account::withdraw(x)
  27. {
  28.  local sum;
  29.  print("Please enter your password :");
  30.  if (password == hidden_input('-'))
  31.    {
  32.     sum = (x < balance)?x:balance;
  33.     balance -= sum;
  34.     print("\n",owner,"'s account has been debited ",sum,".\n");
  35.    }
  36.  else
  37.   {
  38.    sum = 0;
  39.    print("\nSorry! Wrong password.\n");
  40.   }
  41.  return sum;
  42. }
  43.  
  44. account::statement()
  45. {
  46.  print("Please enter your password :");
  47.  if (password == hidden_input('-'))
  48.     {
  49.      print("\n    Date : ",sysvar("Sys$Date"),".\n");
  50.      print("    Account started ",starting_date,".\n");
  51.      print("    ",owner,"'s balance is ",balance,".\n");
  52.     } 
  53.  else
  54.   print("\nSorry! Wrong password.\n");
  55. }
  56.  
  57. account::change_password()
  58. {
  59.  print("Please enter your old password :");
  60.  if (password != hidden_input('-'))
  61.     {
  62.       print("\nSorry! Wrong password.\n");
  63.       return nil;
  64.     }
  65.  print("Please enter your new password :");
  66.  password = hidden_input('-');
  67. }
  68.  
  69. account::has_owner(name)
  70. {
  71.  return (name == owner);
  72. }
  73.