Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. Timer timer = new Timer (1000, new ActionListener ()
  2. {
  3. public void actionPerformed(ActionEvent e)
  4. {
  5. if(secondsCriticZone == 6){
  6. Random r = new Random();
  7. int n = r.nextInt(101);
  8. if(!iniciat){
  9. if(n > 40){
  10. dibuixarRoig = false;
  11. }else{
  12. dibuixarRoig = true;
  13. secondsCriticZone = secondsCriticZone - 1;
  14. }
  15. }else{
  16. if(n > 20){
  17. dibuixarRoig = false;
  18. }else{
  19. dibuixarRoig = true;
  20. secondsCriticZone = secondsCriticZone - 1;
  21. }
  22. }
  23. }else{
  24. if(dibuixarRoig){
  25. if(secondsCriticZone != 0){
  26. secondsCriticZone = secondsCriticZone - 1;
  27. }else{
  28. secondsCriticZone = 6;
  29. dibuixarRoig = false;
  30. iniciat = true;
  31. System.out.println("Es 0 hauria de cambiar de smeafor a verd");
  32. }
  33. }
  34. }
  35.  
  36. }
  37. });
  38. timer.start();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement