Bug 294 - user could pay for dish with negative balance
Summary: user could pay for dish with negative balance
Status: RESOLVED FIXED
Alias: None
Product: Group20
Classification: Unclassified
Component: Canteen (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- enhancement
Assignee: Anders
URL:
Depends on:
Blocks:
 
Reported: 2019-10-25 13:39 HKT by awkakavou2-c
Modified: 2019-11-26 12:57 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 awkakavou2-c 2019-10-25 13:39:16 HKT
User shouldn't be able to purchase a dish/beverage with a negative balance
Comment 3 Anders 2019-11-26 12:55:59 HKT
We have identified the problem, and within the Payment.java class we have added a "try and catch" exception. Initially are we trying to deduct the money of a users balance, but if it not possible (the balance is lower than the price of the order), then we throw an exception:

public void makePayemt() {
	try {
		user.removeFromBalance(order.getPrice());
	} catch (Exception e) {
		//TODO: Handle exception makePayment
		System.out.println(e.getMessage());
	}
}

I report the bug as fixed.
Comment 4 Anders 2019-11-26 12:57:29 HKT
We have identified the problem, and within the Payment.java class we have added a "try and catch" exception. Initially are we trying to deduct the money of a users balance, but if it not possible (the balance is lower than the price of the order), then we throw an exception:

public void makePayemt() {
	try {
		user.removeFromBalance(order.getPrice());
	} catch (Exception e) {
		//TODO: Handle exception makePayment
		System.out.println(e.getMessage());
	}
}

I report the bug as fixed.