-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathG1Mediumpg1.java
172 lines (151 loc) · 8.16 KB
/
G1Mediumpg1.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package com.application.brainfit;
import android.content.Intent;
import android.os.CountDownTimer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
public class G1Mediumpg1 extends AppCompatActivity {
TextView tv1, tv2, tv3, tv4, tv5;
ImageView imgview;
CountDownTimer timer;
RadioGroup rg1, rg2, rg3, rg4, rg5;
RadioButton q1rb1, q1rb2, q1rb3, q1rb4, q2rb1, q2rb2, q2rb3, q2rb4, q3rb1, q3rb2, q4rb1, q4rb2, q4rb3, q4rb4, q5rb1, q5rb2, q5rb3, q5rb4;
Button nextbtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_g1_mediumpg1);
tv1 = (TextView) findViewById(R.id.tv1);
tv2 = (TextView) findViewById(R.id.tv2);
tv3 = (TextView) findViewById(R.id.tv3);
tv4 = (TextView) findViewById(R.id.tv4);
tv5 = (TextView) findViewById(R.id.tv5);
imgview = (ImageView) findViewById(R.id.imgview);
rg1 = (RadioGroup) findViewById(R.id.rg1);
rg2 = (RadioGroup) findViewById(R.id.rg2);
rg3 = (RadioGroup) findViewById(R.id.rg3);
rg4 = (RadioGroup) findViewById(R.id.rg4);
rg5 = (RadioGroup) findViewById(R.id.rg5);
nextbtn = (Button) findViewById(R.id.nextbtn);
timer = new MyCountDown(10000, 1000);
rg1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
q1rb1 = (RadioButton) findViewById(R.id.q1rb1);
q1rb2 = (RadioButton) findViewById(R.id.q1rb2);
q1rb3 = (RadioButton) findViewById(R.id.q1rb3);
q1rb4 = (RadioButton) findViewById(R.id.q1rb4);
}
});
rg2.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
q2rb1 = (RadioButton) findViewById(R.id.q2rb1);
q2rb2 = (RadioButton) findViewById(R.id.q2rb2);
q2rb3 = (RadioButton) findViewById(R.id.q2rb3);
q2rb4 = (RadioButton) findViewById(R.id.q2rb4);
}
});
rg3.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
q3rb1 = (RadioButton) findViewById(R.id.q3rb1);
q3rb2 = (RadioButton) findViewById(R.id.q3rb2);
}
});
rg4.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
q4rb1 = (RadioButton) findViewById(R.id.q4rb1);
q4rb2 = (RadioButton) findViewById(R.id.q4rb2);
q4rb3 = (RadioButton) findViewById(R.id.q4rb3);
q4rb4 = (RadioButton) findViewById(R.id.q4rb4);
}
});
rg5.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
q5rb1 = (RadioButton) findViewById(R.id.q5rb1);
q5rb2 = (RadioButton) findViewById(R.id.q5rb2);
q5rb3 = (RadioButton) findViewById(R.id.q5rb3);
q5rb4 = (RadioButton) findViewById(R.id.q5rb4);
}
});
nextbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int score;
if (rg1.getCheckedRadioButtonId()==-1 || rg2.getCheckedRadioButtonId()==-1 ||rg3.getCheckedRadioButtonId()==-1 ||rg4.getCheckedRadioButtonId()==-1 ||rg5.getCheckedRadioButtonId()==-1){
Toast.makeText(getApplicationContext(), "Please answer all the question", Toast.LENGTH_LONG).show();
}else{
if (q1rb1.isChecked() && q2rb2.isChecked() && q3rb1.isChecked() && q4rb3.isChecked() && q5rb2.isChecked()){
score = 50;
Intent i = new Intent(getApplicationContext(), G1Mediumpg2.class);
i.putExtra("n",score);
startActivity(i);
}else if ((q1rb1.isChecked() && q2rb2.isChecked() && q3rb1.isChecked() && q4rb3.isChecked()) ||
(q1rb1.isChecked() && q2rb2.isChecked() && q3rb1.isChecked() && q5rb2.isChecked()) ||
(q1rb1.isChecked() && q2rb2.isChecked() && q4rb3.isChecked() && q5rb2.isChecked()) ||
(q1rb1.isChecked() && q3rb1.isChecked() && q4rb3.isChecked() && q5rb2.isChecked()) ||
(q2rb2.isChecked() && q3rb1.isChecked() && q4rb3.isChecked() && q5rb2.isChecked())){
score = 40;
Intent i = new Intent(getApplicationContext(), G1Mediumpg2.class);
i.putExtra("n",score);
startActivity(i);
}else if (q1rb1.isChecked() && q2rb2.isChecked() && q3rb1.isChecked() ||
(q1rb1.isChecked() && q2rb2.isChecked() && q4rb3.isChecked()) ||
(q1rb1.isChecked() && q2rb2.isChecked() && q5rb2.isChecked()) ||
(q2rb2.isChecked() && q3rb1.isChecked() && q4rb3.isChecked()) ||
(q2rb2.isChecked() && q3rb1.isChecked() && q5rb2.isChecked()) ||
(q3rb1.isChecked() && q4rb3.isChecked() && q5rb2.isChecked()) ||
(q2rb2.isChecked() && q4rb3.isChecked() && q5rb2.isChecked())){
score = 30;
Intent i = new Intent(getApplicationContext(), G1Mediumpg2.class);
i.putExtra("n",score);
startActivity(i);
}else if (q1rb1.isChecked() && q2rb2.isChecked() || (q1rb1.isChecked() && q3rb1.isChecked()) ||
(q1rb1.isChecked() && q4rb3.isChecked()) || (q1rb1.isChecked() && q5rb2.isChecked()) ||
(q2rb2.isChecked() && q3rb1.isChecked()) || (q2rb2.isChecked() && q4rb3.isChecked()) ||
(q2rb2.isChecked() && q5rb2.isChecked()) || (q3rb1.isChecked() && q4rb3.isChecked()) ||
q3rb1.isChecked() && q5rb2.isChecked() || (q4rb3.isChecked() && q5rb2.isChecked())){
score = 20;
Intent i = new Intent(getApplicationContext(), G1Mediumpg2.class);
i.putExtra("n",score);
startActivity(i);
}else if (q1rb1.isChecked() || q2rb2.isChecked() || q3rb1.isChecked() || q4rb3.isChecked() || q5rb2.isChecked()){
score = 10;
Intent i = new Intent(getApplicationContext(), G1Mediumpg2.class);
i.putExtra("n",score);
startActivity(i);
}else{
score = 0;
Intent i = new Intent(getApplicationContext(), G1Mediumpg2.class);
i.putExtra("n",score);
startActivity(i);
}
}
finish();
}
});
}
private class MyCountDown extends CountDownTimer {
long duration, interval;
public MyCountDown(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
start();
}
@Override
public void onFinish() {
imgview.setVisibility(View.INVISIBLE);
}
@Override
public void onTick(long duration) {
}
}
}