Bug 302 - Dish object accepts negative price
Summary: Dish object accepts negative price
Status: RESOLVED FIXED
Alias: None
Product: Group20
Classification: Unclassified
Component: Dish (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- normal
Deadline: 2019-11-06
Assignee: Anders
URL:
Depends on:
Blocks:
 
Reported: 2019-11-05 17:44 HKT by awkakavou2-c
Modified: 2019-11-05 17:54 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description awkakavou2-c 2019-11-05 17:44:56 HKT
While creating a new dish object a negative price is accepted. Obviously the price should be above 0.
public Dish(String s, double d, int i) {
		this.name = s;
		this.price = d;
		this.id = i;
I believe there should me a message shown to the canteen management that an error has been made and the price should be > 0.
Comment 1 Anders 2019-11-05 17:54:11 HKT
I have identified the problem. Initially we didn't check for negative values in variable "d". The problem has been solved by throwing the following error, when a negative value is encountered:

IllegalArgumentException("Negative price");

The problem is solved, and I mark this bug as "resolved".