Property asking different amounts of constructors

Methods can have optional parameters, but, you can also overload – so, while you seem to want a constructor (because you’re creating objects, but, you could make it methods.. but you do need to make the object first then!):

potentially you could have 2 constructors to allow for those conditions :

public OpenAccount (String name, String LastName, String Housenumber, String Postcode)
{ do stuff }
public OpenAccount (String name, String LastName, String Housenumber, String Postcode, int balance, int min)
{ do stuff }

Or you could do

public OpenAccount (String name, String LastName, String Housenumber, String Postcode, int balance=0, int min=0)
{do stuff}

which allows your to auto set those values if none are provided. I didnt check it works for constructors, but it should.

Leave a Comment