aveenger17

obtienehora

Feb 26th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.83 KB | None | 0 0
  1. import java.util.Calendar;
  2.  
  3. public class obtienehora {
  4.     Calendar calendario = Calendar.getInstance();
  5.     int hora,minuto;
  6.     boolean on = true;
  7.     Thread tiempo,eleva;
  8.    
  9.     obtienehora(){
  10.    
  11.     hora = calendario.get(Calendar.HOUR_OF_DAY);
  12.    
  13.     System.out.print("El puente se baja... \n");
  14.    
  15.     if(hora == 20 || hora == 21 || hora == 22 || hora == 23 || hora == 00){
  16.  
  17.     try {
  18.         eleva.sleep(60*1000);
  19.         on = false;
  20.         if(on==false){
  21.             System.out.print("El puente se levanta... \n");
  22.         }
  23.     } catch (InterruptedException e) {
  24.         // TODO Auto-generated catch block
  25.         e.printStackTrace();
  26.     }
  27.    
  28.     }
  29.    
  30.     if(hora == 1 || hora == 2 || hora == 3 || hora == 4 || hora == 5 || hora == 6){
  31.    
  32.         try {
  33.             eleva.sleep(30*1000);
  34.             on = false;
  35.             if(on==false){
  36.                 System.out.print("El puente se baja... \n");
  37.             }
  38.         } catch (InterruptedException e) {
  39.             // TODO Auto-generated catch block
  40.             e.printStackTrace();
  41.         }
  42.        
  43.         }
  44.  
  45.     if(hora == 7 || hora == 8 || hora == 9 || hora == 10|| hora == 11){
  46.        
  47.         try {
  48.             eleva.sleep(120*1000);
  49.             on = false;
  50.             if(on==false){
  51.                 System.out.print("El puente se baja... \n");
  52.             }
  53.         } catch (InterruptedException e) {
  54.             // TODO Auto-generated catch block
  55.             e.printStackTrace();
  56.         }
  57.        
  58.         }
  59.  
  60.     if(hora == 12 || hora == 13 || hora == 14 || hora == 15 || hora == 16|| hora == 17 || hora == 18 || hora == 19 ){
  61.    
  62.         try {
  63.             eleva.sleep(150*1000);
  64.             on = false;
  65.             if(on==false){
  66.                 System.out.print("El puente se baja... \n");
  67.             }
  68.         } catch (InterruptedException e) {
  69.             // TODO Auto-generated catch block
  70.             e.printStackTrace();
  71.         }
  72.    
  73.     }
  74.    
  75.    
  76.         hora= 0;
  77.         minuto=0;
  78.         hora = calendario.get(Calendar.HOUR);
  79.         minuto = calendario.get(Calendar.MINUTE);
  80.  
  81.         }
  82.    
  83. public static void main(String[] args){
  84.     boolean puente=true;
  85.     do{
  86.     new obtienehora();
  87.     }while(puente=true);
  88.     }
  89.    
  90.    
  91. }
Advertisement
Add Comment
Please, Sign In to add comment