Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In a simple way The objectives of this homework is to let the students develop a

ID: 3641913 • Letter: I

Question

In a simple way

The objectives of this homework is to let the students develop a complete application composed of three different classes to ensure a number of functionalities in the banking system.
The key components of a banking system are: BankCustomer, BankAccount, and Bank.

The customer is defined by his name, his mobile phone number, his address, and a reference to his account. Every BankCustomer has one and only one BankAccount within a given Bank. When we create individual customers, we should provide at least the name, phone number, address. The user of our application should be able to read and modify these attributes.

A BankAccount is defined using four pieces of information: the account number, the account name, the account balance, the name of the owner. Users should be able to create instances of BankAccount by providing at least the account number and the account name. Users should also be able to read the values of each one of the attributes that define the BankAccount, and have the possibility to deposit an amount of money on the account, or to withdraw an amount of money from the account.

The bank is defined by its name, list of customers and the list of customer accounts. Customers are stored as an array of BankCustomer. Accounts stored as an array of BankAccount. The bank required functionalities include:
1. Creation of bank instances: the maximum number of accounts allowed should be provided, the constructor will create an array of bank accounts accordingly,
2. Get the total number of accounts currently in the system,
3. Search: given a string representing an account number, this function return the index of the account with that account number. If the account number doesn’t exist, then a “phoney” (-999) will be returned to indicate failure,
4. Verify if the list of accounts is empty,
5. Verify if the list of accounts is full,
6. Add a bank account to the list of accounts, if the addition is not successful the user should be informed by returning a Boolean (true/false),
7. Get the Account (strictly speaking get a reference to the Account) located at a given position in the list,
8. Deposit an amount of money on a particular account. The amount and the account number are provided. Returns true if the deposit was made successfully, or false otherwise (e.g. in case of wrong account number),
9. Withdraw and amount of money from a particular account. The amount and the account number are provided. Returns true if the withdrawal was made successfully, or false otherwise (e.g. in case of wrong account number),
10. Remove an account from the list of bank accounts. Returns a Boolean as previously,
11. Operations 2 to 10 should also be made available for customers, e.g. we should have the possibility to create new customer, to remove an existing customer, to deposit/withdraw an amount of money on/from the account of a particular customer.
Part 1:
Write the java classes Customer and BankAccount, and a third class BankAccountTester.
In the test method (the main):
Create an instance of BankAccount,
Test all its functionalities (getters, deposit, and withdrawal),
Show how to assign the instance to a particular customer,
Show how you can deposit and withdraw money from the account of a given customer.
Part 2:
Write a java class BankTester, in the main method of this class propose a menu to test all the functionalities of the banking system, and execute banking operations such as:
Create new account, remove an existing account,
Deposit and withdraw money on (and from) a given account,
Check account details,
Create new customers, remove existing customers,
Deposit and withdraw money on (and from) the account of a given customer,
Check customer details,
Any other useful functionalities as described above.

Part 3 a short (one or two pages report) explaining your design and the structure of your codes

Explanation / Answer

//Hi ! I just wanted to tell you that the question is not clear

//about some variables and stuff that i mentioned in my messages.

// The design of this question is not good. Design of your program is very

// important. Whoever gave you this question, please ask them to check it

// and make it better.

// I did some part of your code. It is not good quality code. Perhaps, its good enough

//to give you a start. I dont think i can continue working on your question.

// Please ask someone else. If you want to give me some points for this, go ahead.

// Two classes given here, two given below the answer.


public class BankCustomer
{
    private String name;
    private long mobilePhone;
    private String address;
    private String reference;//a reference to his account.
   
   
    //Constructor
    private BankCustomer(String name, long mobilePhone, String address)
    {
        //name, his mobile phone number, his address
        this.name = name;
        this.mobilePhone = mobilePhone;
        this.address = address;   
       
    }
   
    private BankCustomer(String name, long mobilePhone, String address, String reference)
    {
        //name, his mobile phone number, his address
        this.name = name;
        this.mobilePhone = mobilePhone;
        this.address = address;   
        this.reference = reference;
       
    }
   
   
    //Checks if all data is valid, and only then it allows you
    //to get a bank account! If any data is invalid, return null reference!
    public static BankCustomer getInstance(String name, long mobilePhone, String address)
    {
        BankCustomer bc = null;
       
        if(BankCustomer.isNumberValid(mobilePhone))
        {
            if(BankCustomer.isNameValid(name))
            {
                if(BankCustomer.isAddressValid(address))
                {
                    bc = new BankCustomer(name, mobilePhone, address);
                }
            }
       
        }
       
        return bc;
    }
   
    //Getters
    public String getName(){return this.name;}
    public long getMobilePhone(){return this.mobilePhone;}
    public String getAddress(){return this.address;}
    public String getReference(){return this.reference;}

    //Setters
    public boolean setName(String name)
    {
        if(isNameValid(name))
        {
            this.name = name;
            return true;
        }else return false;
       
    }
   
    public boolean setMobilePhone(long mobilePhone)
    {
        if(isNumberValid(mobilePhone))
        {
            this.mobilePhone = mobilePhone;
            return true;
        }else return false;
       
       
    }
   
    public boolean setAddress(String address)
    {
        if(isAddressValid(address))
        {
            this.address = address;
            return true;
        }else return false;   
       
    }
   
    public boolean setReference(String reference)
    {
        if(isRefValid(reference))
        {
            this.reference = reference;
            return true;
        }else return false;   
       
    }
   
   
    //Other Methods
    public static final boolean isNumberValid(long mobilePhone)
    {
        int numberOfDigits = 4;//The number of digits a mobile phone number should have.
        if(mobilePhone > 0 && Long.toString(mobilePhone).length() == numberOfDigits)
        {
            return true;
        }else{return false;}   
   
    }
   
   
    public static boolean isNameValid(String name)
    {
        return true;//for now, later you can add some checks and make an advanced version!
    }
   
   
    public static boolean isAddressValid(String address)
    {
        return true;//for now, later you can add some checks and make an advanced version!
    }
   
   
    public static boolean isRefValid(String reference)
    {
        return true;//for now, later you can add some checks and make an advanced version!
    }
   
   
}

________________________________________________________________________________________


import java.math.*;

public class BankAccount
{
    private long accountNumber;
    private String accountName;//???
    private BigDecimal accountBalance;
    private String owner;//????
    //Extra stuff i added.
    private BankCustomer reference;
   
   
    //constructors
    BankAccount(long accountNumber, String accountName)
    {
        this.accountNumber = accountNumber;
        this.accountName = accountName;   
       
    }
   
   
    //Getters
    public long getAccountNumber(){return this.accountNumber;}
    public String getAccountName(){return this.accountName;}
    public BigDecimal getAccountBalance(){return this.accountBalance;}
    public String getOwner(){return this.owner;}
    public BankCustomer getReference(){return this.reference;}
   
   
    //Setters
    public void getAccountNumber(long accountNumber){this.accountNumber = accountNumber;}
    public void getAccountName(String accountName){this.accountName = accountName;}
    public void getAccountBalance(BigDecimal accountBalance){this.accountBalance = accountBalance;}
    public void getOwner(String owner){this.owner = owner;}
    public void getReference(BankCustomer reference){this.reference = reference;}
   
    //Other Methods
    public boolean getAccount(long accountNumber, String owner)
    {
        if(this.accountNumber == accountNumber && this.owner.equals(owner))
        {
            return true;
        }else return false;   
       
    }
   
    public BankAccount deposit(BigDecimal deposit)
    {
        int temp = deposit.compareTo(new BigDecimal("0"));
        if(temp == 0 || temp == 1)
        {
            accountBalance.add(deposit);
            return this;
        }else return null;
    }

    public boolean withdraw(BigDecimal withdraw)
    {
        int temp = accountBalance.compareTo(withdraw);
        if(temp == 0 || temp == 1)
        {
            accountBalance.subtract(withdraw);
            return true;
        }else return false;
    }
   
}