Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package aplikacija;
- public class Semafor {
- private int svetlo;
- private final int CRVENO = 1;
- private final int ZUTO1 = 2;
- private final int ZELENO = 3;
- private final int ZUTO2 = 4;
- public void promeniSvetlo(){
- if (svetlo == CRVENO){
- svetlo = ZUTO1;
- } else if (svetlo == ZUTO1){
- svetlo = ZELENO;
- } else if(svetlo == ZELENO){
- svetlo = ZUTO2;
- } else if ( svetlo == ZUTO2){
- svetlo = CRVENO;
- }
- switch(svetlo){
- case CRVENO:
- svetlo = ZUTO1;
- break;
- case ZUTO1:
- svetlo = ZELENO;
- break;
- case ZELENO:
- svetlo = ZUTO2;
- break;
- case ZUTO2:
- svetlo = CRVENO;
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement