Skip to content

Constructors

Sharina Stubbs edited this page Jan 15, 2020 · 1 revision

Constructor Overloading

To create default values, you can make multiple constructors that inherit from each other.

public Business (String name, String description, Integer priceCategory, Integer numberOfStars, ) {
  this.name = name;
  this.description = description;
  this.priceCategory = priceCategory;
  this.numberOfStars = numberOfStars;
}

public Business (String name, String description) {
  this(name, description, priceCategory: 0);
}

public Business (String name, Integer priceCategory) {
  this(name, description: "", priceCategory);
}

public Business (String name) {
  this(name, description: "");
}

public Business (String name) {
  this(name: "");
}
Clone this wiki locally