English 中文(简体)
完整 noob, 机器人应用帮助( 数组)
原标题:Complete noob, Android app help (array)

我实在很抱歉,如果我开始惹恼任何人,我花了几周时间尝试这样做,我需要完成我的软件(quiz),而我似乎无法理解如何实现这一点(所有程序员都要把我的帽子脱下来 ) 。 因此,我将尝试一点一点地解决它。 让我首先向大家概述一下我正在努力做的事情。

页面/活动 1 = 4 按钮到不同的测验目录, 我只是想要一个现在工作。

第2页 = 我想要一个问题和四个可能的答案(打乱),下一个按钮,然后滚动到下一个问题。

最后一页,我希望所有正确的答复加在一起,要么是8/10假想,要么是可能的时间和能力,允许有奖杯的照片和分数界定的颜色。

现在到目前为止,我已经完成了我的布局 我想,拖拉拉,我可以做。

我上星期花了这个星期 试图获得一个数据库 问题和工作答案的答案 但我不能 所以我已经决定 做阵列。

第一个问题是,这是我的阵列的样子, 我已经把它设置在它自己的类, 这是可行的还是愚蠢的?

public class QuestionSets {

String mathsQuestions[]= {
        "What is 10 * 4 =?",
        " How many sides does a cube have?", 
        "What is Pi equal to, to 2 decimal places?", 
        "What is 595 172 correct to the nearest thousand?", 
        "What is 2.5 * 100?", 
        "What is 90 out of 200 as a percentage?", 
        "What is y if y=5x+5 if x is 5?", 
        "What is 66 + 108?", 
        "What is 1 + 0.6?, What is 10 - 8=?"};

String correctAnswers[]= 
    {"40", "6", "3.14", "595 000", "250", "45%", "30", "174", "1.6", "2"};

String option1 [] = 
    {"50", "4", "4.13", "596 000", "25", "40%", "40", "170", "0.7", "4"};

String option2 [] = 
    {"45", "7", "5,14", "600 000", "200", "50%", "25", "178", "7", "80"};

String option3 [] = 
    {"54", "3", "2.13", "500 000", "2000", "90%", "20", "180", "6", "18"};

// ...

正确和不正确的答案与问题是一致的。

我看见有人排成数组 列出我在提问课上 列出的东西,这是否也是正确的?我真的不知道,但我在那里做了这些。

// ...

ArrayList<Integer> mthsQuestions = new ArrayList<Integer>();

ArrayList<Integer> crtAns = new ArrayList<Integer>(); 

ArrayList<Integer> optn1 = new ArrayList<Integer>(); 

ArrayList<Integer> optn2 = new ArrayList<Integer>();

ArrayList<Integer> optn3 = new ArrayList<Integer>(); 

}

还有为什么它们是整数, 不应该是字符串吗?

谢谢 谢谢

最佳回答

您是对的, 它是错误的。 您应该使用 ArrayList< String> 。 您可以在初始化时填写 :

ArrayList<String> optn3 = new ArrayList<String>(Arrays.asList(option3));

但是,从工程角度看,最好把问题和答案放在一个单独的文本文件中,由您的程序读取。这样你就可以改变问题或添加新的问题,而不必重新拼凑程序。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...