Skip to content
Snippets Groups Projects
Commit cf3d4643 authored by HSoreide's avatar HSoreide
Browse files

Implement constructor overloading in Item class

parent 9f32ea36
No related branches found
No related tags found
1 merge request!1Hs item class
......@@ -6,16 +6,21 @@ public class Item {
private String description = "";
private float price;
public Item (Category category, String description, float price){
public Item (Category category, float price){
if(category == null || price <= 1.0f) {
throw new IllegalArgumentException("The item must have a category and a price.");
} else {
this.category = category;
this.price = price;
this.description = description;
}
}
public Item (Category category, String description, float price){
this(category, price);
this.description=description;
}
public Category getCategory() {
return category;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment