home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / a / armbob / !ArmBob / progs / h / account next >
Text File  |  1994-06-06  |  1KB  |  72 lines

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