0

My code asks for input and prints out a color and a statement. But input could be anything, Is there a way to limit to colors?

using Scanner for input

19th May 2017, 1:17 PM
Sheri
Sheri - avatar
4 Réponses
0
for example, you can use select tag with options
19th May 2017, 1:28 PM
Yaroslav Pieskov
Yaroslav Pieskov - avatar
0
what form of color value it must be? 1. words like red, blue, green.... 2. hex: #345465, #2008544, #ffa 3. rgb/rgba 4. hsl/hsla
19th May 2017, 1:31 PM
Yaroslav Pieskov
Yaroslav Pieskov - avatar
0
Using Java: You could just prompt for a list of colors and only check for these. Every other input could be ignored by your script. Your prompt should be in a do..while loop till it's a correct input. There is afaik no way to limit users input, the script have to doublecheck if it's correct or not and give hints back to the user if something wrong. Using HTML etc: you can use option tags
19th May 2017, 1:31 PM
nouseforname
nouseforname - avatar
0
that seems workable, thanks
19th May 2017, 1:34 PM
Sheri
Sheri - avatar