Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Hillary Gaudet
- Date: February 6th, 2020
- Due: February 28th, 2020
- Class: PROG1400
- Assignment 3
- Instructions:
- Create a storage class named BankAccount.
- A BankAccount has fields that hold the account number, the customer's name (2 fields), their address, and the balance
- Create the accessor and mutator methods for each attribute.
- The class will also contain methods to deposit and withdraw an amount (internally updating the stored balance by the amount deposited or withdrawn).
- Create a default constructor to default any numeric attribute to 2 and any string attribute to "empty".
- Create another constructor to allow you to set all attributes stored within the object when the object is declared.
- Create a third construct that allows you set all string attributes when the object is declared and defaults all the numeric attributes to 2.
- Create a display function to show the class's current state.
- Create a class named TestBankAccount and test all methods you created for your BankAccount class.
- */
- //Creating testBankAccount program
- public class testBankAccount {
- public static void main(String[] args ) {
- }
- }
- //Creating storage class
- class bankAccount {
- private int accountNumber;
- private String firstName;
- private String lastName;
- private String address;
- private double balance;
- //Creating accessor methods
- public int getAccountNumber() {
- return accountNumber;
- }
- public String getFirstName() {
- return firstName;
- }
- public String getLastName() {
- return lastName;
- }
- public String getAddress() {
- return address;
- }
- public double getBalance() {
- return balance;
- }
- //Creating mutator methods
- public void setAccountNumber(int accountNumber) {
- this.accountNumber = accountNumber;
- }
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
- public void setAddress(String address) {
- this.address = address;
- }
- public void setBalance(double balance) {
- this.balance = balance;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement