java - How to reset class variable to default value 0? -


if can tell me different way this, appreciate. how reset class variable 0, or default value? use class variable cause don't know way this. after game ends place result in class variable, cause have 2 rounds of game, , after first round ends add result, , class variable cause after restart game method still holds previous result. after second round on add result previous result , close activity , set text result text button. when click new game, button still holds text, cause class variable still holds it. how reset class variable when go on new game?

here's game code, of (100 points start amount, , gets lower in game progress):

public class asocijacije extends activity implements onclicklistener{  int brojpoenaasocijacije = 100;     public static int brojpoenaukupno; 

then skip here lot of code , here's add points. brojpoenaasocijacije points earned in round:

brojpoenaukupno = brojpoenaukupno + brojpoenaasocijacije; 

here's main activity set points class variable button (where added comment):

public class izbor extends activity implements onclicklistener{      asocijacije poeni = new asocijacije();      button toplohladno, asocijacije, cigle, spojnice, nazad, poenith, poeniaso, poenicigle, poenispojnice;     textview naslov;     public boolean music;     mediaplayer buttonclicks, buttonback;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);          requestwindowfeature(window.feature_no_title);   //full screen         getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen);          setcontentview(r.layout.izbor);          sharedpreferences getprefs = preferencemanager.getdefaultsharedpreferences(getbasecontext());         music = getprefs.getboolean("checkbox", true);          addlisteneronbutton();      }        private void addlisteneronbutton() {         buttonclicks = mediaplayer.create(this, r.raw.click);         buttonback = mediaplayer.create(this, r.raw.button31);          typeface naslovtype = typeface.createfromasset(getassets(), "lobster.ttf");         typeface dugmad = typeface.createfromasset(getassets(), "bebas.ttf");         naslov = (textview) findviewbyid(r.id.tvizbornaslov);         toplohladno = (button) findviewbyid(r.id.bizbor1);         asocijacije = (button) findviewbyid(r.id.bizbor2);         cigle = (button) findviewbyid(r.id.bizbor3);         spojnice = (button) findviewbyid(r.id.bizbor4);         nazad = (button) findviewbyid(r.id.bizbornazad);         poenith = (button) findviewbyid(r.id.bpoenith);         poeniaso = (button) findviewbyid(r.id.bpoeniaso);         poenicigle = (button) findviewbyid(r.id.bpoenicigle);         poenispojnice = (button) findviewbyid(r.id.bpoenispojnice);         naslov.settypeface(naslovtype);         toplohladno.settypeface(dugmad);         asocijacije.settypeface(dugmad);         cigle.settypeface(dugmad);         spojnice.settypeface(dugmad);         nazad.settypeface(dugmad);         poeniaso.settypeface(dugmad);          toplohladno.setonclicklistener(this);         asocijacije.setonclicklistener(this);         cigle.setonclicklistener(this);         spojnice.setonclicklistener(this);         nazad.setonclicklistener(this);      }       @override     protected void onstart() {         super.onstart();          poeniaso.settext("" + poeni.brojpoenaukupno); //i here     }      public void onclick(view v) {         switch(v.getid()){         case r.id.bizbor1:             if(music == true){                 buttonclicks.start();                     }             startactivity(new intent("rs.androidaplikacije.toplo_hladno.game"));             break;         case r.id.bizbor2:             if(music == true){                 buttonclicks.start();                     }             startactivity(new intent("rs.androidaplikacije.toplo_hladno.asocijacije"));             break;         case r.id.bizbor3:             if(music == true){                 buttonclicks.start();                     }              break;         case r.id.bizbor4:             if(music == true){                 buttonclicks.start();                     }              break;         case r.id.bizbornazad:             if(music == true){                 buttonback.start();                     }             poeniaso.settext("");             finish();             break;         }      }  } 

because don't find piece of code start new game, can say:

asocijacije.brojpoenaukupno = 0; 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -