Skip to content

Commit f4ee8c7

Browse files
committed
feat #12: checking the question list size
1 parent e33733a commit f4ee8c7

File tree

3 files changed

+171
-2
lines changed

3 files changed

+171
-2
lines changed

QuizApp/app/src/main/java/com/example/quizapp/QuizQuestionActivity.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ package com.example.quizapp
22

33
import androidx.appcompat.app.AppCompatActivity
44
import android.os.Bundle
5+
import android.util.Log
6+
import com.example.quizapp.data.Constants
57

68
class QuizQuestionActivity : AppCompatActivity() {
79
override fun onCreate(savedInstanceState: Bundle?) {
810
super.onCreate(savedInstanceState)
911
setContentView(R.layout.activity_quiz_question)
12+
13+
// get the question from constants
14+
val questionList = Constants.getQuestions()
15+
Log.i("Question size", "${questionList.size}")
1016
}
1117
}
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
package com.example.quizapp.data
2+
3+
import com.example.quizapp.R
4+
5+
// creating question objects
6+
7+
object Constants {
8+
// creating array list for question
9+
fun getQuestions(): ArrayList<Question> {
10+
val questionList = ArrayList<Question>()
11+
12+
// first question
13+
val que1 = Question(
14+
1,
15+
"What county does this flag belong to?",
16+
R.drawable.ic_flag_of_argentina,
17+
"Argentina",
18+
"Australia",
19+
"Armenia",
20+
"Austria",
21+
1
22+
)
23+
24+
// add question in the array list
25+
questionList.add(que1)
26+
27+
// 2
28+
val que2 = Question(
29+
2,
30+
"What country does this flag belong to?",
31+
R.drawable.ic_flag_of_australia,
32+
"Angola",
33+
"Austria",
34+
"Australia",
35+
"Armenia",
36+
3
37+
)
38+
39+
questionList.add(que2)
40+
41+
// 3
42+
val que3 = Question(
43+
3,
44+
"What country does this flag belong to?",
45+
R.drawable.ic_flag_of_brazil,
46+
"Belarus",
47+
"Belize",
48+
"Brunei",
49+
"Brazil",
50+
4
51+
)
52+
53+
questionList.add(que3)
54+
55+
// 4
56+
val que4 = Question(
57+
4,
58+
"What country does this flag belong to?",
59+
R.drawable.ic_flag_of_belgium,
60+
"Bahamas",
61+
"Belgium",
62+
"Barbados",
63+
"Belize",
64+
2
65+
)
66+
67+
questionList.add(que4)
68+
69+
// 5
70+
val que5 = Question(
71+
5,
72+
"What country does this flag belong to?",
73+
R.drawable.ic_flag_of_fiji,
74+
"Gabon",
75+
"France",
76+
"Fiji",
77+
"Finland",
78+
3
79+
)
80+
81+
questionList.add(que5)
82+
83+
// 6
84+
val que6 = Question(
85+
6,
86+
"What country does this flag belong to?",
87+
R.drawable.ic_flag_of_germany,
88+
"Germany",
89+
"Georgia",
90+
"Greece",
91+
"none of these",
92+
1
93+
)
94+
95+
questionList.add(que6)
96+
97+
// 7
98+
val que7 = Question(
99+
7,
100+
"What country does this flag belong to?",
101+
R.drawable.ic_flag_of_denmark,
102+
"Dominica",
103+
"Egypt",
104+
"Denmark",
105+
"Ethiopia",
106+
3
107+
)
108+
109+
questionList.add(que7)
110+
111+
// 8
112+
val que8 = Question(
113+
8,
114+
"What country does this flag belong to?",
115+
R.drawable.ic_flag_of_india,
116+
"Ireland",
117+
"Iran",
118+
"Hungary",
119+
"India",
120+
4
121+
)
122+
123+
questionList.add(que8)
124+
125+
// 9
126+
val que9 = Question(
127+
9,
128+
"What country does this flag belong to?",
129+
R.drawable.ic_flag_of_new_zealand,
130+
"Australia",
131+
"New Zealand",
132+
"Tuvalu",
133+
"United States of America",
134+
2
135+
)
136+
137+
questionList.add(que9)
138+
139+
// 10
140+
val que10 = Question(
141+
10,
142+
"What country does this flag belong to?",
143+
R.drawable.ic_flag_of_kuwait,
144+
"Kuwait",
145+
"Jordan",
146+
"Sudan",
147+
"Palestine",
148+
1
149+
)
150+
questionList.add(que10)
151+
152+
// return the question list
153+
return questionList
154+
}
155+
}
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
package com.example.quizapp.data
22

3-
class Question {
4-
}
3+
data class Question(
4+
val id: Int,
5+
val question: String,
6+
val image: Int,
7+
val optionOne: String,
8+
val optionTwo: String,
9+
val optionThree: String,
10+
val optionFour: String,
11+
val correctAnswer: Int
12+
)

0 commit comments

Comments
 (0)