Note that there are some explanatory texts on larger screens.

plurals
  1. POModifying Constructors
    primarykey
    data
    text
    <p>I have an assignment that requires me to modify constructors. The instruction is:</p> <p>Modify both Account constructors First constructor will accept account number as a parameter and set account number property (class variable) Second constructor will accept account number and initial account balance and set corresponding properties</p> <p>What I do not understand is "set account number property" and "set corresponding properties."</p> <p>My two constructors are:</p> <pre><code>public Account(String newAccountType, double depositAmount, long accountNumber) { this.accountType = newAccountType; Random randomGenerator = new Random(); // Random Number Generator for account number creation this.accountNumber = randomGenerator.nextInt(10000); setAccountStatus("Active"); // call account status setter to set the status to active DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Date date = new Date(); this.dateOpened = dateFormat.format(date).toString(); this.lastTransaction = dateFormat.format(date).toString(); deposit(depositAmount); System.out.println("Account successfully opened! Your current balance is: " + this.accountBalance); } </code></pre> <p>and</p> <pre><code>public void deposit(double depositAmount, long accountNumber, int initialAccountNum, double accountBalance) { if (this.accountStatus == "Active") { this.accountBalance = this.accountBalance + depositAmount; System.out.println("Deposit successful"); System.out.println("Balance: " + this.accountBalance); DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); this.lastTransaction = dateFormat.format(date).toString(); } else { System.out.println("Account is inactive"); } } </code></pre> <p>I added the accountNumber into the first and second constructors already. What is the correct way to complete this task? Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload