fix: Classnames in abstractaccount
This commit is contained in:
@@ -1,24 +1,33 @@
|
||||
package oving7.abstractaccount;
|
||||
|
||||
/**
|
||||
* A bank consists of many different types of accounts: credit accounts, debit accounts, savings
|
||||
* accounts, etc. Since these have a lot in common, e.g. all have a balance, it is practical to
|
||||
* collect as much of the common logic as possible in a superclass, which all can inherit from.
|
||||
* However, this superclass is not a type of account in itself, and therefore we make it
|
||||
* {@code abstract}, so that it cannot be instantiated. The concrete account classes that inherit
|
||||
* from it, must of course be instantiable. The methods defined in the {@code AbstractAccount} class
|
||||
* A bank consists of many different types of accounts: credit accounts, debit
|
||||
* accounts, savings
|
||||
* accounts, etc. Since these have a lot in common, e.g. all have a balance, it
|
||||
* is practical to
|
||||
* collect as much of the common logic as possible in a superclass, which all
|
||||
* can inherit from.
|
||||
* However, this superclass is not a type of account in itself, and therefore we
|
||||
* make it
|
||||
* {@code abstract}, so that it cannot be instantiated. The concrete account
|
||||
* classes that inherit
|
||||
* from it, must of course be instantiable. The methods defined in the
|
||||
* {@code AbstractAccount} class
|
||||
* is similar to that of the Account interface in the SavingsAccount task.
|
||||
*/
|
||||
public abstract class AbstractAccountDocs {
|
||||
public abstract class AbstractAccount {
|
||||
|
||||
// AbstractAccount has a state {@code balance} for the account balance. The balance should
|
||||
// AbstractAccount has a state {@code balance} for the account balance. The
|
||||
// balance should
|
||||
// either be set to 0.0 by default or in the constructor
|
||||
|
||||
// TODO: Add fields and potentially a constructor here
|
||||
|
||||
/**
|
||||
* Decreases the account balance by the specified amount. Note that the rules for withdrawals
|
||||
* are different for the classes that implement {@code AbstractAccount}, and must therefore be
|
||||
* Decreases the account balance by the specified amount. Note that the rules
|
||||
* for withdrawals
|
||||
* are different for the classes that implement {@code AbstractAccount}, and
|
||||
* must therefore be
|
||||
* implemented in each class.
|
||||
*
|
||||
* @param amount the amount to withdraw
|
||||
@@ -37,7 +46,8 @@ public abstract class AbstractAccountDocs {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method calls the {@link #internalWithdraw()} method, which is implemented in each
|
||||
* This method calls the {@link #internalWithdraw()} method, which is
|
||||
* implemented in each
|
||||
* subclass.
|
||||
*
|
||||
* @param amount the amount to withdraw
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
package oving7.abstractaccount;
|
||||
|
||||
/**
|
||||
* A {@code CreditAccount} has in addition to {@code balance} a state for {@code creditLine}, i.e.
|
||||
* available credit on the account. This credit line allows the account to be overdrawn (that the
|
||||
* balance is negative) within the credit line. If {@link #internalWithdraw()} tries to withdraw
|
||||
* A {@code CreditAccount} has in addition to {@code balance} a state for
|
||||
* {@code creditLine}, i.e.
|
||||
* available credit on the account. This credit line allows the account to be
|
||||
* overdrawn (that the
|
||||
* balance is negative) within the credit line. If {@link #internalWithdraw()}
|
||||
* tries to withdraw
|
||||
* more money than is available, taking the credit line into account, an
|
||||
* {@code IllegalArgumentException} should be thrown.
|
||||
*
|
||||
* @see AbstractAccount
|
||||
*/
|
||||
public class CreditAccountDocs extends AbstractAccountDocs {
|
||||
public class CreditAccount extends AbstractAccount {
|
||||
|
||||
// TODO: Add fields here
|
||||
|
||||
@@ -19,7 +22,7 @@ public class CreditAccountDocs extends AbstractAccountDocs {
|
||||
* @param creditLine the credit line
|
||||
* @throws IllegalArgumentException if the credit line is negative
|
||||
*/
|
||||
public CreditAccountDocs(double creditLine) {
|
||||
public CreditAccount(double creditLine) {
|
||||
// TODO: Implement this constructor
|
||||
}
|
||||
|
||||
@@ -40,7 +43,8 @@ public class CreditAccountDocs extends AbstractAccountDocs {
|
||||
*
|
||||
* @param creditLine the credit line
|
||||
* @throws IllegalArgumentException if the credit line is negative
|
||||
* @throws IllegalStateException if the new credit line does not cover the existing balance
|
||||
* @throws IllegalStateException if the new credit line does not cover the
|
||||
* existing balance
|
||||
*
|
||||
* @see CreditAccountTest#testCreditLine()
|
||||
*/
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
package oving7.abstractaccount;
|
||||
|
||||
/**
|
||||
* A debit account is the simplest form of account, where the only requirement is that the balance
|
||||
* at any time must be greater than or equal to {@code 0.0}. {@code DebitAccount} extends (inherits
|
||||
* from) {@link AbstractAccount} and ensure that the balance never falls below {@code 0.0}. If an
|
||||
* attempt is made to withdraw more money than is available, an {@code IllegalArgumentException}
|
||||
* A debit account is the simplest form of account, where the only requirement
|
||||
* is that the balance
|
||||
* at any time must be greater than or equal to {@code 0.0}.
|
||||
* {@code DebitAccount} extends (inherits
|
||||
* from) {@link AbstractAccount} and ensure that the balance never falls below
|
||||
* {@code 0.0}. If an
|
||||
* attempt is made to withdraw more money than is available, an
|
||||
* {@code IllegalArgumentException}
|
||||
* should be thrown.
|
||||
*
|
||||
* @see AbstractAccount
|
||||
*/
|
||||
public class DebitAccountDocs extends AbstractAccountDocs {
|
||||
public class DebitAccount extends AbstractAccount {
|
||||
|
||||
// TODO: Override abstract method here
|
||||
}
|
||||
|
||||
@@ -1,26 +1,32 @@
|
||||
package oving7.abstractaccount;
|
||||
|
||||
/**
|
||||
* A {@code SavingsAccount} can only have a positive balance. In addition, the account has
|
||||
* withdrawal restrictions. A {@code SavingsAccount} has {@code x} number of {@code withdrawals}. If
|
||||
* you want to withdraw money after all withdrawals have been used up, the balance should be charged
|
||||
* a {@code fee}. If the balance is too low to cover the fee, an {@code IllegalArgumentException}
|
||||
* A {@code SavingsAccount} can only have a positive balance. In addition, the
|
||||
* account has
|
||||
* withdrawal restrictions. A {@code SavingsAccount} has {@code x} number of
|
||||
* {@code withdrawals}. If
|
||||
* you want to withdraw money after all withdrawals have been used up, the
|
||||
* balance should be charged
|
||||
* a {@code fee}. If the balance is too low to cover the fee, an
|
||||
* {@code IllegalArgumentException}
|
||||
* should be thrown.
|
||||
*
|
||||
* @see AbstractAccount
|
||||
*/
|
||||
public class SavingsAccountDocs extends AbstractAccountDocs {
|
||||
public class SavingsAccount extends AbstractAccount {
|
||||
|
||||
// TODO: Add fields here
|
||||
|
||||
/**
|
||||
* Initializes a new {@code SavingsAccount} with the specified number of withdrawals and fee.
|
||||
* Initializes a new {@code SavingsAccount} with the specified number of
|
||||
* withdrawals and fee.
|
||||
*
|
||||
* @param withdrawals the number of withdrawals
|
||||
* @param fee the fee
|
||||
* @throws IllegalArgumentException if the number of withdrawals or the fee is negative
|
||||
* @param fee the fee
|
||||
* @throws IllegalArgumentException if the number of withdrawals or the fee is
|
||||
* negative
|
||||
*/
|
||||
public SavingsAccountDocs(int withdrawals, double fee) {
|
||||
public SavingsAccount(int withdrawals, double fee) {
|
||||
// TODO: Implement this constructor
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user