Bug 321 - Empty string for Dish object allowed
Summary: Empty string for Dish object allowed
Status: RESOLVED FIXED
Alias: None
Product: Group20
Classification: Unclassified
Component: Dish (show other bugs)
Version: unspecified
Hardware: PC Windows
: Low minor
Assignee: Anders
URL:
Depends on:
Blocks:
 
Reported: 2019-12-01 03:20 HKT by awkakavou2-c
Modified: 2019-12-08 17:20 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:20:01 HKT
Hi, i noticed that it is possible to add a dish with an empty name, I don't think this should be allowed, an exception should be created.
public Dish(String s, double d, int i){
	this.name = s;
Comment 1 Anders 2019-12-08 17:20:47 HKT
Hi, I have added an if-else statement to check if the string (dish name) has a length less than one. If that is the case then an error will be thrown. See code below:

if(s.length() < 1)
	throw new IllegalArgumentException("Empty name");
else
	this.name = s;

I mark this bug as fixed.