From 9e7e182b481760f9a2a6dd804810899f8ce6211e Mon Sep 17 00:00:00 2001 From: Phong Tran Date: Sat, 5 Sep 2015 23:42:34 -0500 Subject: [PATCH] Needed to add AccountRecord --- Exercise 17.2/src/AccountRecord.java | 75 ++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 Exercise 17.2/src/AccountRecord.java diff --git a/Exercise 17.2/src/AccountRecord.java b/Exercise 17.2/src/AccountRecord.java new file mode 100644 index 0000000..4b5a1fa --- /dev/null +++ b/Exercise 17.2/src/AccountRecord.java @@ -0,0 +1,75 @@ +/** + * Fig. 17.4: SequentialFile.AccountRecord.java + * SequentialFile.AccountRecord class maintains information for one account. + */ + +public class AccountRecord +{ + private int account; + private String firstName; + private String lastName; + private double balance; + + // no-argument constructor calls other constructor with default values + public AccountRecord() + { + this(0, "", "", 0.0); // call four-argument contsructor + } + + // initialize a record + public AccountRecord(int acct, String first, String last, double bal) + { + setAccount(acct); + setFirstName(first); + setLastName(last); + setBalance(bal); + } // end four-argument SequentialFile.AccountRecord constructor + + // set account number + public void setAccount(int acct) + { + account = acct; + } // end method setAccount + + // get account number + public int getAccount() + { + return account; + } // end method getAccount + + // set first name + public void setFirstName(String first) + { + firstName = first; + } // end method setFirstName + + // get first name + public String getFirstName() + { + return firstName; + } // end method getFirstName + + // set last name + public void setLastName(String last) + { + lastName = last; + } // end method setLastName + + // get last name + public String getLastName() + { + return lastName; + } // end method getLastName + + // set balance + public void setBalance(double bal) + { + balance = bal; + } // end method setBalance + + // get balance + public double getBalance() + { + return balance; + } // end method getBalance +} // end class SequentialFile.AccountRecord \ No newline at end of file