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

Created class for storing budget names

parent c1167321
No related branches found
No related tags found
1 merge request!43Merging frontend-testing into master
package no.ntnu.idatt1002.demo.data.Budget;
import java.util.ArrayList;
import java.util.List;
public class BudgetRegister {
private final List<String> budgetNames;
public BudgetRegister() {
budgetNames = new ArrayList<>();
}
public List<String> getBudgetNames() {
return this.budgetNames;
}
public void addBudgetName(String name) {
if (name == null) throw new IllegalArgumentException("Name cannot be null");
if (name.isBlank()) throw new IllegalArgumentException("Name cannot be blank");
budgetNames.add(name);
}
public void removeBudgetName(String name) {
if (name == null) throw new IllegalArgumentException("Name cannot be null");
if (name.isBlank()) throw new IllegalArgumentException("Name cannot be blank");
budgetNames.add(name);
}
@Override
public String toString() {
StringBuilder namesToString = new StringBuilder();
budgetNames.forEach(name -> namesToString.append(name).append("\n"));
return namesToString.toString();
}
}
package no.ntnu.idatt1002.demo.data.Budget;public class FileHandlingBudgetArchive {
}
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