Skip to content

Commit

Permalink
Merge pull request nus-cs2113-AY2223S2#61 from Sherlock-YH/master
Browse files Browse the repository at this point in the history
add authorship for Sherlock-YH
  • Loading branch information
tyuyang authored Mar 23, 2023
2 parents 8f86072 + fc0f638 commit c15ee8a
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 16 deletions.
7 changes: 4 additions & 3 deletions src/main/java/seedu/bankwithus/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class Account {
private String name;
private String balance;

//@@author Sherlock-YH
/**
* Instantiates an account object
*
Expand All @@ -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);
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/seedu/bankwithus/AccountList.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private String askUserForBalance() {
return askUserForBalance();
}
}

//@@author Sherlock-YH
/**
* Creates a new account and adds it to the AccountList.
*
Expand All @@ -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
*/
Expand All @@ -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
*
Expand All @@ -147,7 +147,7 @@ public String getAllAccountDetails() throws AccountNotFoundException {
return temp.toString();
}
}

//@@author
public void showBal() {
String balance = getMainAccount().getAccountBalance();
ui.showBal(balance);
Expand Down Expand Up @@ -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)) {
Expand All @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/bankwithus/BankWithUs.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public Ui getUi() {
return ui;
}

//@@author Sherlock-YH
/**
* Exit the programme, save the data and show farewell message
*
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/bankwithus/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/bankwithus/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void createNewFile() throws IOException {
ui.showFileCreated();
}

//@@author Sherlock-YH
/**
* This method saves all account details to data/save.txt
*
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/seedu/bankwithus/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -168,25 +168,25 @@ 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!");
System.out.println("Name: " + acc.getAccountName());
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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package seedu.bankwithus.exceptions;

//@@author Sherlock-YH
public class AccountNotFoundException extends Exception {

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package seedu.bankwithus.exceptions;

//@@author Sherlock-YH
/**
* thrown when there is no account at all
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package seedu.bankwithus.exceptions;

//@@author Sherlock-YH
/**
* Thrown when the saved file has no data
*/
Expand Down

0 comments on commit c15ee8a

Please sign in to comment.