Bug 322 - Discount for ComboItem out of bounds
Summary: Discount for ComboItem out of bounds
Status: RESOLVED FIXED
Alias: None
Product: Group20
Classification: Unclassified
Component: ComboItem (show other bugs)
Version: unspecified
Hardware: PC Windows
: Low normal
Assignee: Anders
URL:
Depends on:
Blocks:
 
Reported: 2019-12-01 03:29 HKT by awkakavou2-c
Modified: 2019-12-08 17:14 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-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.