Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Nov 14th, 2018 95 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. package com.example.dell.quizapp;
  2.  
  3. import android.app.Activity;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.widget.CheckBox;
  8. import android.widget.EditText;
  9. import android.widget.RadioButton;
  10. import android.widget.Toast;
  11.  
  12. public class MainActivity extends AppCompatActivity {
  13.     int Score = 0;
  14.  
  15.     @Override
  16.     protected void onCreate(Bundle savedInstanceState) {
  17.         super.onCreate(savedInstanceState);
  18.         setContentView(R.layout.activity_main);
  19.     }
  20.  
  21.     public void displayscore(View view) {
  22.  
  23. boolean allCorrect = Score==4;
  24. if (allCorrect){
  25.     Toast.makeText(this, "Congrats!", Toast.LENGTH_SHORT).show();
  26. }else {
  27.     Toast.makeText(this, "your score is " + Score + " out of 4", Toast.LENGTH_SHORT).show();
  28.     Score=0;
  29. }
  30.  
  31.  
  32.  
  33.  
  34.     }
  35.  
  36.  
  37.  
  38.  
  39.     public void onEiffelRadioButtonClicked(View view) {
  40.  
  41.         RadioButton radioButton = (RadioButton) findViewById(R.id.eiffel);
  42.         boolean isradioButtonChecked = radioButton.isChecked();
  43.         if (isradioButtonChecked) {
  44.             Score++;
  45.         }
  46.         }
  47.     public void onBkhalifaRadioButtonClicked(View view) {
  48.  
  49.         RadioButton radioButton = (RadioButton) findViewById(R.id.burj_khalifa);
  50.         boolean isradioButtonChecked = radioButton.isChecked();
  51.         if (isradioButtonChecked) {
  52.             Score--;
  53.         }
  54.     }
  55.  
  56.  
  57.  
  58.     public void onChinaRadioButtonClicked(View view) {
  59.  
  60.         RadioButton radioButton = (RadioButton) findViewById(R.id.china);
  61.         boolean isradioButtonChecked = radioButton.isChecked();
  62.         if (isradioButtonChecked) {
  63.             Score++;
  64.         }
  65.     }
  66.  
  67.     public void onRussiaRadioButtonClicked(View view) {
  68.  
  69.         RadioButton radioButton = (RadioButton) findViewById(R.id.russia);
  70.         boolean isradioButtonChecked = radioButton.isChecked();
  71.         if (isradioButtonChecked) {
  72.             Score--;
  73.         }
  74.     }
  75.  
  76.  
  77.  
  78.     public void Checkboxes(View view) {
  79.  
  80.         final CheckBox checkBox1 = (CheckBox) findViewById(R.id.denmark);
  81.         final CheckBox checkBox2 = (CheckBox) findViewById(R.id.portugal);
  82.         final CheckBox checkBox3 = (CheckBox) findViewById(R.id.italy);
  83.  
  84.         if (checkBox2.isChecked() &&
  85.                 checkBox3.isChecked() &&
  86.                 !checkBox1.isChecked()) {
  87.             // do something
  88.             Score++;
  89.         }else {
  90.             Score--;
  91.         }
  92.  
  93.     }
  94.  
  95.  
  96.     public void Q4AnswerField(View view) {
  97.         EditText editText = (EditText) findViewById(R.id.Q4Answer);
  98.         String userString = editText.getText().toString();
  99.         String answer = "Egypt";
  100.         boolean isAnswerTrue = "Egypt".equalsIgnoreCase("egypt");
  101.  
  102.         if (isAnswerTrue) {
  103.             Score++;
  104.         }else {
  105.             Score--;
  106.         }
  107.     }
  108.  
  109.  
  110.  
  111. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top