I have a button that when clicked should count up until it reaches the resetTouch limit and then reset to 0.
However that is not what is happening.
int resetTouch = 4;
int number = 1;
int touches1 = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
//adds number of touches
public void setTouches1 (View view){
if (touches1 < resetTouch){
touches1 = touches1 + number;
displayTeamTouches(touches1);
}
else{
touches1 = 0;
}
This sorta works, however instead of stopping at 3 it goes to 4. I have to click the + button twice at this point to get it to reset to 1. I want it to increment to 3 and then reset to 0.
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire