Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Demo first #162

Open
temi-ro opened this issue Jul 5, 2019 · 1 comment
Open

Bug Demo first #162

temi-ro opened this issue Jul 5, 2019 · 1 comment

Comments

@temi-ro
Copy link

temi-ro commented Jul 5, 2019

Hello! What's your name? tem
1: Green, like Nature
2: Yellow, like a Sunflower
3: Blue, like the Sky
hello, tem. What's your favourite colour? 4
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
at java.util.ArrayList.rangeCheck(ArrayList.java:657)
at java.util.ArrayList.get(ArrayList.java:433)
at study.learn.storeys.engine.prompters.SimplePrompter.await(SimplePrompter.java:64)
at study.learn.storeys.engine.prompters.SimplePrompter.await(SimplePrompter.java:77)
at study.learn.storeys.engine.demo.Demo.interact(Demo.java:30)
at study.learn.storeys.engine.demo.Menu.lambda$interact$0(Menu.java:38)
at study.learn.storeys.engine.prompters.SimplePrompter.await(SimplePrompter.java:77)
at study.learn.storeys.engine.demo.Menu.interact(Menu.java:36)
at study.learn.storeys.engine.Main.main(Main.java:32)

@edewit
Copy link
Member

edewit commented Jul 5, 2019

@temir20 what's missing here is a check to see if the given value is valid (e.g. the number must be between 0 ( zero is a number ) and the length of the options - 1 ( because we start at zero )

Add a check here: https://github.com/vorburger/minecraft-storeys-maker/blob/master/engine/src/main/java/study/learn/storeys/engine/prompters/SimplePrompter.java#L64

Even better would be that all answers have a validate method so that we can tell the user that that option is not valid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants