Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @Wojciech Czyż
- * @v0.0.7
- */
- import java.util.Observable;
- import java.util.Random;
- public class timer extends Observable
- {
- private boolean countflag;
- private boolean clksrc;
- private boolean tickint;
- private boolean enable;
- private int syst_rvr;
- private int syst_cvr;
- private int syst_calib;
- public timer()
- {
- Random losowa = new Random();
- syst_rvr = losowa.nextInt(16777216);
- syst_calib = 20;
- syst_cvr = syst_calib;
- clksrc = false;
- enable = false;
- tickint = false;
- countflag = false;
- }
- public void tick()
- {
- if (enable == true)
- {
- if (syst_cvr == 1)
- {
- countflag = true;
- syst_cvr--;
- //W sumie syst_rvr też można resetnąć
- }
- else if (syst_cvr == 0 && syst_rvr > 0)
- {
- Random losowa = new Random();
- syst_cvr = syst_rvr;
- syst_rvr = losowa.nextInt(16777216);
- }
- else
- syst_cvr--;
- System.out.println("Tick time!");
- }
- }
- public void syst_rvrWrite(int rvr)
- {
- if (rvr > 0)
- {
- syst_rvr = rvr;
- }
- else if (rvr == 0)
- {
- syst_rvr = rvr;
- enable = false;
- }
- }
- public int syst_rvrRead()
- {
- return syst_rvr;
- }
- public void syst_csrRead()
- {
- System.out.println("Countflag ma wartość: " +countflag);
- System.out.println("Enablema wartość: " +enable);
- System.out.println("Clksrc ma wartość: " +clksrc);
- System.out.println("Tickint ma wartość: " +tickint);
- if (countflag == true)
- {
- countflag = false;
- System.out.println("Flaga zostala wyzerowana");
- }
- }
- public void syst_cvrWrite(int cvr)
- {
- if (countflag == true)
- {
- countflag = false;
- System.out.println("Flaga zostala wyzerowana");
- }
- syst_cvr = 0;
- }
- public int syst_cvrRead()
- {
- return syst_cvr;
- }
- public boolean isTickint()
- {
- return tickint;
- }
- public boolean isCountflag()
- {
- if (countflag == true)
- {
- countflag = false;
- System.out.println("Flaga zostala wyzerowana");
- return true;
- }
- else
- {
- return false;
- }
- }
- public boolean isClksrc()
- {
- return clksrc;
- }
- public boolean isEnable()
- {
- return enable;
- }
- public void setTickint(boolean x)
- {
- tickint = x;
- }
- public void setCountflag(boolean x)
- {
- countflag = x;
- }
- public void setClksrc(boolean x)
- {
- clksrc = x;
- }
- public void setEnable(boolean x)
- {
- enable = x;
- }
- public boolean canChange()
- {
- if (enable == true && countflag == false && syst_rvr > 0)
- return true;
- else
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement