jeudi 22 février 2018

Loop to determine out come of multiple checkboxes being checked from list

I'm trying to take a list of checkboxes and create a loop that does the following: If 3 out of 5 boxes are checked then it subtracts 1 from the opponents score

If 4 out of 5 boxes are checked then it subtracts 1 from the opponents score

If 5 out of 5 boxes are checked then it subtracts 1 from the opponents score

I'm new to java and android studio. Any help would be greatly appreciated!

public class MainActivity extends AppCompatActivity {
    int scoreNearCorner = 10;`enter code here`
    int scoreFarCorner = 10;
    String wNearCorner = "W";
    String wFarCorner = "W";
    String lNearCorner = "L";
    String lFarCorner = "L";

    CheckBox chebox = (CheckBox) findViewById(R.id.checkBox);

    CheckBox chebox2 = (CheckBox) findViewById(R.id.checkBox2);

    CheckBox chebox3 = (CheckBox) findViewById(R.id.checkBox3);

    CheckBox chebox4 = (CheckBox) findViewById(R.id.checkBox4);

    CheckBox chebox5 = (CheckBox) findViewById(R.id.checkBox5);

    int count = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

}

public  void onCheckboxClicked(View view) {


    ArrayList checkboxes = new ArrayList(5);
    checkboxes.add(chebox);
    checkboxes.add(chebox2);
    checkboxes.add(chebox3);
    checkboxes.add(chebox4);
    checkboxes.add(chebox5);




Aucun commentaire:

Enregistrer un commentaire