I was able to create a beverage with just an empty string. I suggest the constructor should check if the string is empty upon object creating. The fix should be done in the code below: public Beverage(String s, double d, int i) { this.name = s; this.price = d; this.id = i; }
Hi, i fixed it by writing an exception which does not accept any input that is less than 1 character. public class Beverage implements Item { private String name; private double price; private int id; public Beverage(String s, double d, int i) { if(s.length() < 1) throw new IllegalArgumentException("Empty name"); else this.name = s;