Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import androidx.annotation.Nullable;
import java.util.Random;
public class SecondActivity extends Activity {
Button accept, nButton;
EditText question, answer;
ProgressBar progressBar;
private yQuiz Quiz = new yQuiz();
int x = 0;
Random r;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
accept.findViewById(R.id.accept);
question.findViewById(R.id.question);
answer.findViewById(R.id.answer);
progressBar.findViewById(R.id.progressBar);
nButton.findViewById(R.id.nbutton);
nButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(SecondActivity.this, yLevelActivity.class);
startActivity(intent);
}
});
accept.setOnClickListener(new View.OnClickListener() {
public void onClick(View view){
if(question.getText().length() != 0 && answer.getText().length() !=0 ){
Quiz.nQuestions[x] = String.valueOf(question.getText());
Quiz.nCorrectAnswer[x] = String.valueOf(answer.getText());
if(x==7) {
nButton.setVisibility(View.VISIBLE);
nButton.setClickable(true);
}
if(Integer.parseInt(Quiz.nCorrectAnswer[x])>=10 && Integer.parseInt(Quiz.nCorrectAnswer[x])<100){
Quiz.nChoices[x][0] = String.valueOf(r.nextInt()%100);
Quiz.nChoices[x][1] = String.valueOf(r.nextInt()%100);
Quiz.nChoices[x][2] = String.valueOf(answer.getText());
Quiz.nChoices[x][3] = String.valueOf(r.nextInt()%100);
}
else if(Integer.parseInt(Quiz.nCorrectAnswer[x])>=100 && Integer.parseInt(Quiz.nCorrectAnswer[x])<1000){
Quiz.nChoices[x][0] = String.valueOf(r.nextInt()%1000);
Quiz.nChoices[x][1] = String.valueOf(answer.getText());
Quiz.nChoices[x][2] = String.valueOf(r.nextInt()%1000);
Quiz.nChoices[x][3] = String.valueOf(r.nextInt()%1000);
}
else if(Integer.parseInt(Quiz.nCorrectAnswer[x])>=1000 && Integer.parseInt(Quiz.nCorrectAnswer[x])<10000){
Quiz.nChoices[x][0] = String.valueOf(r.nextInt()%10000);
Quiz.nChoices[x][1] = String.valueOf(r.nextInt()%10000);
Quiz.nChoices[x][2] = String.valueOf(r.nextInt()%10000);
Quiz.nChoices[x][3] = String.valueOf(answer.getText());
}
else if(Integer.parseInt(Quiz.nCorrectAnswer[x])>=10000 && Integer.parseInt(Quiz.nCorrectAnswer[x])<100000){
Quiz.nChoices[x][0] = String.valueOf(answer.getText());
Quiz.nChoices[x][1] = String.valueOf(r.nextInt()%100000);
Quiz.nChoices[x][2] = String.valueOf(r.nextInt()%100000);
Quiz.nChoices[x][3] = String.valueOf(r.nextInt()%100000);
}
else if(Integer.parseInt(Quiz.nCorrectAnswer[x])>=1 && Integer.parseInt(Quiz.nCorrectAnswer[x])<10){
Quiz.nChoices[x][0] = String.valueOf(answer.getText());
Quiz.nChoices[x][1] = String.valueOf(r.nextInt()%10);
Quiz.nChoices[x][2] = String.valueOf(r.nextInt()%10);
Quiz.nChoices[x][3] = String.valueOf(r.nextInt()%10);
}
x++;
progressBar.setProgress(x);
}
}
});
}
}