oop - Select attribute value from list-Java -


i have class called car, class has attributes such as: id, name, price, color , size. when creating object, color , size want list select attribute value from. don't want user write "black" or "small", want find them somewhere in app.

car c1 = new car(1, "super car", 152.5, "black", "small"); 

does can me that?

you should have list of possible values available user pick one. following example color (just simple example, without going deep java constructs each scenario):

list<string> color = new arraylist<string>(); color.add("black"); color.add("white"); // etc  car c1 = new car(1, "supercar", 152.5, color.get(userselectedoptionindex), "smal"); 

here, userselectedoptionindex should index of option user chose in gui.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -