From fc0f638c3925b444c857ab44f6be29821bc2ca16 Mon Sep 17 00:00:00 2001 From: Sherlock-YH Date: Thu, 23 Mar 2023 12:53:05 +0800 Subject: [PATCH] add authorship for Sherlock-YH --- src/main/java/seedu/bankwithus/Account.java | 7 ++++--- src/main/java/seedu/bankwithus/AccountList.java | 11 +++++++---- src/main/java/seedu/bankwithus/BankWithUs.java | 3 ++- src/main/java/seedu/bankwithus/Parser.java | 2 +- src/main/java/seedu/bankwithus/Storage.java | 1 + src/main/java/seedu/bankwithus/Ui.java | 14 +++++++------- .../exceptions/AccountNotFoundException.java | 1 + .../bankwithus/exceptions/NoAccountException.java | 1 + .../exceptions/SaveFileIsEmptyException.java | 1 + 9 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/main/java/seedu/bankwithus/Account.java b/src/main/java/seedu/bankwithus/Account.java index 0ff7e2ea08..f551f4baf1 100644 --- a/src/main/java/seedu/bankwithus/Account.java +++ b/src/main/java/seedu/bankwithus/Account.java @@ -6,6 +6,7 @@ public class Account { private String name; private String balance; + //@@author Sherlock-YH /** * Instantiates an account object * @@ -16,15 +17,15 @@ public Account(String name, String balance) { this.name = name; this.balance = balance; } - + //@@author Sherlock-YH public String getAccountName() { return name; } - + //@@author Sherlock-YH public String getAccountBalance() { return balance; } - + //@@author public void addBalance(float balanceToBeAdded) { DecimalFormat df = new DecimalFormat("#.##"); String formatted = df.format(Float.parseFloat(balance) + balanceToBeAdded); diff --git a/src/main/java/seedu/bankwithus/AccountList.java b/src/main/java/seedu/bankwithus/AccountList.java index 700c17fad4..6bed9dba79 100644 --- a/src/main/java/seedu/bankwithus/AccountList.java +++ b/src/main/java/seedu/bankwithus/AccountList.java @@ -108,7 +108,7 @@ private String askUserForBalance() { return askUserForBalance(); } } - + //@@author Sherlock-YH /** * Creates a new account and adds it to the AccountList. * @@ -120,7 +120,7 @@ public void addAccount(String name, String balance) { accounts.add(newAccount); ui.showNewAccountAdded(newAccount); } - + //@@author /** * Creates a new Account for a first time user */ @@ -129,7 +129,7 @@ public void createNewAccount() { String balance = askUserForBalance(); addAccount(userName, balance); } - + //@@author Sherlock-YH /** * Name and balance are separated by ; prepared to be saved * @@ -147,7 +147,7 @@ public String getAllAccountDetails() throws AccountNotFoundException { return temp.toString(); } } - + //@@author public void showBal() { String balance = getMainAccount().getAccountBalance(); ui.showBal(balance); @@ -177,6 +177,7 @@ public void withdrawMoney(String withdrawAmountString) throws NumberFormatExcept } } + //@@author Sherlock-YH public void deleteAccount(String name) { for (Account acc : accounts) { if (acc.getAccountName().contains(name)) { @@ -188,10 +189,12 @@ public void deleteAccount(String name) { ui.showNoAccountFound(); } + //@@author Sherlock-YH public int getSize() { return accounts.size(); } + //@@author Sherlock-YH public void switchMainAccount(String accName) throws NoAccountException { //swap acc to the head of AccountList if (accounts.size() == 0) { diff --git a/src/main/java/seedu/bankwithus/BankWithUs.java b/src/main/java/seedu/bankwithus/BankWithUs.java index 570192d890..62f89e952a 100644 --- a/src/main/java/seedu/bankwithus/BankWithUs.java +++ b/src/main/java/seedu/bankwithus/BankWithUs.java @@ -56,6 +56,7 @@ public Ui getUi() { return ui; } + //@@author Sherlock-YH /** * Exit the programme, save the data and show farewell message * @@ -72,7 +73,7 @@ public void exit() throws IOException { throw e; } } - + //@@author /** * The main command and output loop. Takes in user input line by line * and gives it to the parser to execute the command. diff --git a/src/main/java/seedu/bankwithus/Parser.java b/src/main/java/seedu/bankwithus/Parser.java index fdcf250373..d0691ab8e0 100644 --- a/src/main/java/seedu/bankwithus/Parser.java +++ b/src/main/java/seedu/bankwithus/Parser.java @@ -109,7 +109,7 @@ public void parseUserInput(String input) throws CommandNotFoundException, IOExce throw new CommandNotFoundException(); } } - + //@@author Sherlock-YH /** * Parses the save file. Takes in the scanner to the save file, * and splits the name and balance by ; character. Part of diff --git a/src/main/java/seedu/bankwithus/Storage.java b/src/main/java/seedu/bankwithus/Storage.java index 49c8eccec6..237616bbca 100644 --- a/src/main/java/seedu/bankwithus/Storage.java +++ b/src/main/java/seedu/bankwithus/Storage.java @@ -45,6 +45,7 @@ public void createNewFile() throws IOException { ui.showFileCreated(); } + //@@author Sherlock-YH /** * This method saves all account details to data/save.txt * diff --git a/src/main/java/seedu/bankwithus/Ui.java b/src/main/java/seedu/bankwithus/Ui.java index 2583f991dc..6974a168f3 100644 --- a/src/main/java/seedu/bankwithus/Ui.java +++ b/src/main/java/seedu/bankwithus/Ui.java @@ -148,17 +148,17 @@ public void showCorruptedSaveFileError() { public void showForbiddenCharacterError() { System.out.println("Please do not put the chacter ';' in the name."); } - + //@@author Sherlock-YH public void showAccountDeleted(String name) { System.out.println("Account: " + name + " deleted"); printLine(); } - + //@@author Sherlock-YH public void showNoAccountFound() { System.out.println("Account is not found, please rectify the name"); printLine(); } - + //@@author Sherlock-YH public void showAccountNotFound() { System.out.println("There is no account"); printLine(); @@ -168,12 +168,12 @@ public void showEmptyFile() { System.out.println("There is no saved account, please create a new account"); printLine(); } - + //@@author Sherlock-YH public void showNumberOfAccount(int accSize) { System.out.println("Found " + accSize + " Account"); printLine(); } - + //@@author Sherlock-YH public void showNewAccountAdded(Account acc) { printLine(); System.out.println("Account created!"); @@ -181,12 +181,12 @@ public void showNewAccountAdded(Account acc) { System.out.println("Balance: $" + acc.getAccountBalance()); printLine(); } - + //@@author Sherlock-YH public void showThereIsOnlyOneAccount() { System.out.println("There is only one account"); printLine(); } - + //@@author Sherlock-YH public void showMainAccountSwitched() { System.out.println("Main Account switched"); printLine(); diff --git a/src/main/java/seedu/bankwithus/exceptions/AccountNotFoundException.java b/src/main/java/seedu/bankwithus/exceptions/AccountNotFoundException.java index 0b6f2f4378..b71278dfc5 100644 --- a/src/main/java/seedu/bankwithus/exceptions/AccountNotFoundException.java +++ b/src/main/java/seedu/bankwithus/exceptions/AccountNotFoundException.java @@ -1,5 +1,6 @@ package seedu.bankwithus.exceptions; +//@@author Sherlock-YH public class AccountNotFoundException extends Exception { } diff --git a/src/main/java/seedu/bankwithus/exceptions/NoAccountException.java b/src/main/java/seedu/bankwithus/exceptions/NoAccountException.java index e7bfac8d56..6e70aeeaf5 100644 --- a/src/main/java/seedu/bankwithus/exceptions/NoAccountException.java +++ b/src/main/java/seedu/bankwithus/exceptions/NoAccountException.java @@ -1,5 +1,6 @@ package seedu.bankwithus.exceptions; +//@@author Sherlock-YH /** * thrown when there is no account at all */ diff --git a/src/main/java/seedu/bankwithus/exceptions/SaveFileIsEmptyException.java b/src/main/java/seedu/bankwithus/exceptions/SaveFileIsEmptyException.java index 1c91bc65b9..d015cb7717 100644 --- a/src/main/java/seedu/bankwithus/exceptions/SaveFileIsEmptyException.java +++ b/src/main/java/seedu/bankwithus/exceptions/SaveFileIsEmptyException.java @@ -1,5 +1,6 @@ package seedu.bankwithus.exceptions; +//@@author Sherlock-YH /** * Thrown when the saved file has no data */