Hi, I'm just wondering what benefit a parameterized constructor (other than giving the option of overloading the default constructor)? If I had a default constructor along with getters and setters, what would be the point of also having a parameterized constructor?
package business; import java.text.NumberFormat; public class Pokemon { //the instance variables private String name; private String type; private double price; //the default constructor public Pokemon(){ name = ""; type = ""; price = 0; } //parameterized constructor public Pokemon(String name, String type, double price){ this.name = name; this.type = type; this.price = price; } //getters and setters public void setName(String name){ this.name = name; } /* //alternative way to declare setter public void setName(String theName){ name = theName; }*/ public String getName(){ return name; } public void setType(String type){ this.type = type; } public String getType(){ return type; } public void setPrice(double price){ this.price = price; } public double getPrice(){ return price; } //a custom method for the price variable public String getPriceFormatted(){ NumberFormat currency = NumberFormat.getCurrencyInstance(); String priceFormatted = currency.format(price); return priceFormatted; } }