Bug 322

Summary: Discount for ComboItem out of bounds
Product: Group20 Reporter: awkakavou2-c
Component: ComboItemAssignee: Anders <agmller2-c>
Status: RESOLVED FIXED    
Severity: normal CC: agmller2-c
Priority: Low    
Version: unspecified   
Hardware: PC   
OS: Windows   

Description awkakavou2-c 2019-12-01 03:29:07 HKT
Hi, I noticed that there isn't any fixed number for the discount, meaning that some discount values are available to input, but don't make sense. For example I entered discount d = -5, which later makes the price of the dish: "price * discount",resulting in the price of the dish being less than zero. A fix should be made that only positive values should be allowed.
	public ComboItem(String n, ArrayList<Item> l, double d, int i
                       //*
                       not relevant code
                      *//
			this.discount = d;
		
	}
Comment 1 Anders 2019-12-08 17:14:42 HKT
Thank you for the bug. I've added an if-else statement to code part you've mentioned to make sure that the discount value is between 0 and 1.00. See code below:

if(d > 0 && d < 1.00)
	this.discount = d;
else
	throw new IllegalArgumentException("Discount out of bounds");

I mark this bug as fixed.