Java Enums - Number add() and classification method -


I am creating an API for a Phonebook that has 3 different types of phone numbers: fax, home, work, cell

I want to add a number for a specific type but do not want to classify FX, Home, Work etc. as primitive types because I am thinking that I can change it at a later date I am

I was trying to use these but I am not clear how I can use it efficiently in this matter.

So far I have worked for this part:

  Private em number type {fax, work, home, cell} class phone number {phone number (int number) , Number type type) {this.number = number; This.Type = type; } .. getter and setter for the above version ..}  

But I still can not find how I can specify a specific phone number for specific phone type.

I am still confused.

Thank you.

Thank you.

You can type a method

  Type the number type Phone number Number (string phone number) {// logic to differentiate between different types of phone numbers // Benefit: You can also check invalid phone number values. }  

You can call this method before calling the method you have mentioned.

Number Type nt = Type Address Phone Number (number); Phone number numberNumber = new phone number (number, nt);

I would suggest using strings instead of intents for phone numbers.


Comments