Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add maximum description length to ensure description is not too long #54

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/financeproject/data/data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Stocks|400.00|Oct 24 2024 12:00PM|INVESTMENT
Stocks|400.00|Oct 24 2024 12:00PM|INVESTMENT
Stocks|400.12|Oct 24 2024 12:00PM|INVESTMENT
6 changes: 6 additions & 0 deletions src/main/java/financialtransactions/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@


public abstract class Transaction<T> {
private static final int NAME_MAX_LEN = 30;
protected String name;
protected double amount;
protected BaseDate date;
protected T category;

public Transaction(String name, double amount, String date) {
if (name.length() > NAME_MAX_LEN) {
System.out.println("Sorry, the description inputted exceeds the maximum permeable length. " +
"Please try again.");
return;
}
this.name = name;
this.amount = amount;
if (date == null){
Expand Down
Loading