Bug 294

Summary: user could pay for dish with negative balance
Product: Group20 Reporter: awkakavou2-c
Component: CanteenAssignee: Anders <agmller2-c>
Status: RESOLVED FIXED    
Severity: enhancement CC: awkakavou2-c
Priority: ---    
Version: unspecified   
Hardware: PC   
OS: Windows   

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.