aidandeno
aidandeno

Reputation: 307

Is there an easier way to write lots of constructors with different signatures?

I'm creating a class called Location that has 7 instance variables, such as street, suburb, city, etc.

While I was creating all the different constructors with different signatures (including the default constructor), I started thinking that there must be an easier way to go about doing this. If I had a class with 15 or so instance variables, I could spend all day typing out the possibilities.

Am I right in thinking that there is an easier method?

Upvotes: 0

Views: 89

Answers (1)

filip
filip

Reputation: 414

You can use the builder pattern or chain the constructors.

Upvotes: 3

Related Questions