Bug 303 - Creating user with negative balance
Summary: Creating user with negative balance
Status: RESOLVED FIXED
Alias: None
Product: Group20
Classification: Unclassified
Component: User (show other bugs)
Version: 1.0
Hardware: PC Linux
: --- normal
Assignee: awkakavou2-c
URL:
Depends on:
Blocks:
 
Reported: 2019-11-05 17:49 HKT by Anders
Modified: 2019-11-05 17:53 HKT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anders 2019-11-05 17:49:13 HKT
In my testing I encountered, that I was able to make a user with a negative balance. The system should check if the prompted balance is less than 0. I assume a check should be made in the constructor of <b> User.java </b>.
Comment 1 awkakavou2-c 2019-11-05 17:53:53 HKT
I believe I have resolved the issue by "throwing" an exception when trying to add a user with a negative balance.

public User(String s, double d, int i) throws IllegalArgumentException {
		// not relevant
		
		if(d < 0)
			throw new IllegalArgumentException("Negative balance");
		else
			this.balance = d;
		
		// not relevant
	}
Now when trying to create user with negative balance the message "Negative balance" is returned.