Project Description
For this week's project, you'll create a simple Bank Account Management System that demonstrates the principles of encapsulation.
Requirements:
- Create a BankAccount class with private fields for account number, balance, and owner name
- Implement proper getters and setters for each field
- Include methods for deposit and withdrawal with appropriate validation
- Create a read-only field for the account creation date
- Implement a method to print account details
- In the main method, create multiple bank accounts and perform various operations
Here's a template to get you started:
import java.util.Date;
public class BankAccount {
private String accountNumber;
private double balance;
private String ownerName;
private final Date creationDate;
// Constructor
public BankAccount(String accountNumber, String ownerName) {
// Initialize fields here
}
// Implement getters and setters
public void deposit(double amount) {
// Implement deposit logic
}
public void withdraw(double amount) {
// Implement withdrawal logic
}
public void printAccountDetails() {
// Print account details
}
public static void main(String[] args) {
// Create bank accounts and perform operations
}
}
Implement the BankAccount class and demonstrate its usage in the main method. Make sure to include proper encapsulation and validation. Use the online compiler to write and test your code. Once you're satisfied with your program, paste a sample output of creating an account, depositing money, withdrawing money, and printing account details in the autograder to check your work.