Skip to content
Snippets Groups Projects
Commit e3144e54 authored by Harry Linrui XU's avatar Harry Linrui XU
Browse files

Added isEmpty method to FileHandlingBudget

parent d8a19a8b
No related branches found
No related tags found
10 merge requests!43Merging frontend-testing into master,!38"Made progressbar dynamic in accordance to spending. Added balance field....,!37Made the sub progress bars respond to changes in expense,!32Added input validation to add dialog boxes.,!30Redesigned scenes,!29Redesigned scenes,!28Redesigned scenes,!26Redesigned Main menu and expense/income windows,!24Merging frontend-testing with master,!23Merging frontend-testing and master
......@@ -36,6 +36,23 @@ public class FileHandlingBudget {
}
}
/**
* Method for checking if a .register file is empty.
*
* @param fileTitle the name of the file you want to check
* @return true or false depending on if file is empty.
* @throws IOException if an input or output exception occurred.
*/
public boolean isEmpty(String fileTitle) throws IOException {
try (BufferedReader br = new BufferedReader(new FileReader(filePath + fileTitle + fileType))) {
if (br.readLine() == null) {
return true;
} else {
return false;
}
}
}
/**
* Method for reading (getting) a Budget from a file.
*
......@@ -74,11 +91,14 @@ public class FileHandlingBudget {
} else if (line.startsWith(FileHandlingBudget.budgetDescription)) {
budgetDescription = line.replace(FileHandlingBudget.budgetDescription,"");
}
if ((line.isEmpty() || (nextLine == null)) && (expenseCategory!=null)) {
if ((line.isEmpty() || (nextLine == null)) /*&& (expenseCategory!=null)*/) {
if(generalBudget == null){
System.out.println("hello 1");
System.out.println(budgetPeriod);
generalBudget = new GeneralBudget(budgetPeriod,maxAmount);
generalBudget.addToBudget(budgetAmount,budgetDescription,expenseCategory);
} else{
System.out.println("hello2");
generalBudget.addToBudget(budgetAmount,budgetDescription,expenseCategory);
}
}
......
date=2023-03-01
description=twelve
amount=12.0
isReoccuring=Reoccurring
isRecurring=Not recurring
category=CLOTHES
date=2023-03-11
description=1111
amount=121.0
isReoccuring=Reoccurring
isRecurring=Not recurring
category=OTHER
date=2024-03-16
description=1112111
amount=1000.0
isReoccuring=Not reoccurring
isRecurring=Not recurring
category=FOOD
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment