Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.14 KB | None | 0 0
  1. /*
  2.  
  3. Author: Hillary Gaudet
  4. Date: February 6th, 2020
  5. Due: February 28th, 2020
  6. Class: PROG1400
  7.  
  8. Assignment 3
  9.  
  10. Instructions:
  11.  
  12. Create a storage class named BankAccount.
  13. A BankAccount has fields that hold the account number, the customer's name (2 fields), their address, and the balance
  14. Create the accessor and mutator methods for each attribute.
  15. The class will also contain methods to deposit and withdraw an amount (internally updating the stored balance by the amount deposited or withdrawn).
  16. Create a default constructor to default any numeric attribute to 2 and any string attribute to "empty".
  17. Create another constructor to allow you to set all attributes stored within the object when the object is declared.
  18. Create a third construct that allows you set all string attributes when the object is declared and defaults all the numeric attributes to 2.
  19. Create a display function to show the class's current state.
  20. Create a class named TestBankAccount and test all methods you created for your BankAccount class.
  21.  
  22. */
  23.  
  24. //Creating testBankAccount program
  25.  
  26. public class testBankAccount {
  27.    
  28.     public static void main(String[] args ) {
  29.  
  30.     }
  31. }
  32.  
  33. //Creating storage class
  34.  
  35. class bankAccount {
  36.  
  37.     private int accountNumber;
  38.     private String firstName;
  39.     private String lastName;
  40.     private String address;
  41.     private double balance;
  42.    
  43.  
  44. //Creating accessor methods
  45.  
  46. public int getAccountNumber() {
  47.  
  48.     return accountNumber;
  49.  
  50. }
  51.  
  52. public String getFirstName() {
  53.  
  54.     return firstName;
  55.  
  56. }
  57.  
  58. public String getLastName() {
  59.  
  60.     return lastName;
  61.  
  62. }
  63.  
  64. public String getAddress() {
  65.  
  66.     return address;
  67.  
  68. }
  69.  
  70. public double getBalance() {
  71.  
  72.     return balance;
  73.  
  74. }
  75.  
  76. //Creating mutator methods
  77.  
  78. public void setAccountNumber(int accountNumber) {
  79.  
  80.     this.accountNumber = accountNumber;
  81.  
  82. }
  83.  
  84. public void setFirstName(String firstName) {
  85.  
  86.     this.firstName = firstName;
  87.  
  88. }
  89.  
  90. public void setLastName(String lastName) {
  91.  
  92.     this.lastName = lastName;
  93.  
  94. }
  95.  
  96. public void setAddress(String address) {
  97.  
  98.     this.address = address;
  99.  
  100. }
  101.  
  102. public void setBalance(double balance) {
  103.  
  104.     this.balance = balance;
  105.  
  106. }
  107.  
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement