I am creating a library for image loading and caching. I want the user programmer to select the file extension between .png and .jpeg that is want to it to be selected from this 2 only and if programmer types another extension then it must show error. How can I do so?
Share
If i understood your question right, you want to create a library, where you handle images, and when the programmer, who uses your library wants to instantiate your image handling class/classes, you want him/her to choose between jpg and png?
If so, your best option is to create an enum:
And in your actual image-manipulating class:
When the user-programmer uses it: