Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Yurij Krot
3,818 PointsArrays in apps
Hi, everyone I want create test, bases on FunFacts app. How put into array Questions and variants of answers. And can it`s be different tipe of items, like Y/N, or CheckBoxes, or input field?
1 Answer
Gunjeet Hattar
14,483 PointsHi Yurij,
Of what I can make from your description you are more inclined towards creating a quiz kind of app, where the user can select one the answers for a given question. These answers are of different form element types for e.g. check boxes, drop down etc.
You can put question in one array and answers in another. use a global random variable and use it to call the question with their respective answers. For each answer you may select a different form element type.
If you can give a little more description of what exactly you aim for it would help.
Also you can check out this tutorial on creating a quiz app Code TutPlus . it uses string arrays to store answers, which could also be a good idea.
Yurij Krot
3,818 PointsYurij Krot
3,818 PointsThank You, it`s good answer. So, I will have 3 arrays:
```public String[] questions = {"1?", "2?", "3?"};
public String[][] variantsAnsvers;
variantsAnsvers[0][0] = "Bollean"; variantsAnsvers[0][1] = "";
variantsAnsvers[1][0] = "Checbox"; variantsAnsvers[0][1] = "variant 1, variant 2, variant 3, variant 4"; / how its done?
variantsAnsvers[1][0] = "Choose"; variantsAnsvers[0][1] = "variant 1, variant 2, variant 3, variant 4";
public String[] usersAnswers;```
And second problem what I see: How to change in design, at screen, buttons for diffrent types of answers?