home *** CD-ROM | disk | FTP | other *** search
- /* Accounts GCW 02/03/94 */
- class account
- {
- balance; /* An account's state */
- owner;
- password;
- starting_date;
-
- withdraw(x); /* An account's methods */
- statement();
- change_password();
- has_owner(name);
- }
-
- account::account(amount,name)
- {
- balance = (amount>0)?amount:0;
- owner = name;
- print("Enter ",name,"'s password here: ");
- password = hidden_input('-');
- starting_date = sysvar("Sys$Date");
- return this;
- }
-
- account::withdraw(x)
- {
- local sum;
- print("Please enter your password :");
- if (password == hidden_input('-'))
- {
- sum = (x < balance)?x:balance;
- balance -= sum;
- print("\n",owner,"'s account has been debited ",sum,".\n");
- }
- else
- {
- sum = 0;
- print("\nSorry! Wrong password.\n");
- }
- return sum;
- }
-
- account::statement()
- {
- print("Please enter your password :");
- if (password == hidden_input('-'))
- {
- print("\n Date : ",sysvar("Sys$Date"),".\n");
- print(" Account started ",starting_date,".\n");
- print(" ",owner,"'s balance is ",balance,".\n");
- }
- else
- print("\nSorry! Wrong password.\n");
- }
-
- account::change_password()
- {
- print("Please enter your old password :");
- if (password != hidden_input('-'))
- {
- print("\nSorry! Wrong password.\n");
- return nil;
- }
- print("Please enter your new password :");
- password = hidden_input('-');
- }
-
- account::has_owner(name)
- {
- return (name == owner);
- }
-