Advertisement
urksiful

Lopez_Hacienda

Oct 11th, 2015
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.38 KB | None | 0 0
  1.  
  2. import java.io.BufferedReader;
  3. import java.io.InputStreamReader;
  4. import java.io.IOException;
  5.  
  6. import java.util.Scanner;
  7.  
  8.  
  9.  
  10. /**
  11.  *
  12.  * @author uriel
  13.  */
  14. public class Hacienda {
  15.     user inicio = new user();
  16.     int timeV1 = 0, timeV2 = 0;
  17.    
  18.     public static void main(String[] args) {
  19.        
  20.         Hacienda p1 = new Hacienda();
  21.         Scanner x = new Scanner(System.in);
  22.         BufferedReader xr = new BufferedReader(new InputStreamReader(System.in));
  23.        
  24.         p1.inicio = null;
  25.         int ope=0, time=0, opt=0, terco=0;
  26.         String name;
  27.        
  28.        
  29.  
  30.         try{
  31.         do{
  32.             System.out.println("1. Realizar Operación "
  33.                     + "\n2. Avanzar de Usuario");
  34.            
  35.             opt = x.nextInt();
  36.            
  37.             switch(opt){
  38.                
  39.                 case 1:
  40.                     System.out.println("Ingresa nombre");
  41.                      name = xr.readLine();
  42.                    
  43.                     System.out.println("A continuación seleccione la operación a realizar\n");
  44.                     System.out.println("1. Darse de alta (Time: 30 min)"
  45.                             + "\n2. Solicitar FIEL  (Time: 20 min) "
  46.                             + "\n3. Actualizar FIEL (Time 15 min)  "
  47.                             + "\n4. Generar Recibos/Facturas  (Time 45 min)"
  48.                             + "\n5. Aclaraciones     (Time: 40 min)\n");
  49.                    
  50.                     ope = x.nextInt();
  51.                     switch(ope){
  52.                         case 1:
  53.                             time = 30;
  54.                             break;
  55.                         case 2:
  56.                             time = 20;
  57.                             break;
  58.                         case 3:
  59.                             time = 15;
  60.                             break;
  61.                         case 4:
  62.                             time = 45;
  63.                             break;
  64.                         case 5:
  65.                             time = 40;
  66.                             break;
  67.                            
  68.                     }
  69.                     if(p1.timeV1 >179 && p1.timeV2 > 179){
  70.                         System.out.println("Deseas Esperar "+(p1.timeV1)+" min en la ventanilla 1"
  71.                                 + "\n y "+(p1.timeV2)+" min en la ventanilla 2");
  72.                         System.out.println("1). Continuar con mi trámite "
  73.                                 + "\n2. Cancelar Operación");
  74.                         terco = x.nextInt();
  75.                         if(terco == 1){
  76.                            
  77.                             p1.InsertarUser(name, ope, time);
  78.                         }else{
  79.                            
  80.                             System.out.println("Esperemos no haya mucha fila la siguiente vez.");
  81.                         }
  82.                     }else{
  83.                         System.out.println("Se registrara con "+name);
  84.                         p1.InsertarUser(name, ope, time);
  85.                        
  86.                     }        
  87.                            
  88.                     break;
  89.                 case 2:
  90.                     p1.AvanzarUser(p1.inicio.time);
  91.                     break;
  92.             }
  93.        
  94.         }while(true);
  95.        
  96.     }catch(IOException err){}
  97.        
  98.        
  99.     }
  100.    
  101.     public void InsertarUser(String nombre, int operacion, int time) {
  102.         user nuevo = new user();
  103.         nuevo.nombre = nombre;
  104.         nuevo.operacion = operacion;
  105.         nuevo.time = time;
  106.         if(timeV1 == timeV2){
  107.             nuevo.ventana = 1;
  108.             timeV1 += nuevo.time;
  109.             System.out.println("Bienvenido "+nuevo.nombre+""
  110.                 + "\nTiempo de espera "+timeV1+" mins"
  111.                     + "\nVentanilla 1\n");
  112.         }else if(timeV1 < timeV2){
  113.             nuevo.ventana = 1;
  114.             timeV1 += nuevo.time;
  115.             System.out.println("Bienvenido "+nuevo.nombre+""
  116.                 + "\nTiempo de espera "+timeV1+" mins"
  117.                     + "\nVentanilla 1\n");
  118.         }else if(timeV1 > timeV2){
  119.             nuevo.ventana = 2;
  120.             timeV2 += nuevo.time;
  121.             System.out.println("\nBienvenido "+nuevo.nombre+""
  122.                 + "\nTiempo de espera "+timeV2+" mins"
  123.                     + "\nVentanilla 2\n");
  124.         }
  125.        
  126.        
  127.         if (inicio == null) {
  128.             inicio = nuevo;
  129.         } else {
  130.             user aux = new user();
  131.             aux = inicio;
  132.             while (aux.sig != null) {
  133.                 aux = aux.sig;
  134.             }
  135.             aux.sig = nuevo;
  136.         }
  137.  
  138.     }
  139.    
  140.  
  141.     public void AvanzarUser(int cont) {
  142.         user aux = new user();
  143.         //user auxant = new user();
  144.         aux = inicio;
  145.         if (inicio.time == cont) {
  146.             if(inicio.ventana == 1){
  147.                 timeV1 -= inicio.time;
  148.             }else{
  149.                 timeV2 -= inicio.time;
  150.             }
  151.             inicio = aux.sig;
  152.            
  153.         } else {
  154.            
  155.             System.out.println("ERROR: Depurame PEERRRAAA");
  156.             /*while (aux.time != cont && aux != null) {
  157.                 auxant = aux;
  158.                 aux = aux.sig;
  159.             }
  160.             auxant.sig = aux.sig;*/
  161.         }
  162.  
  163.     }
  164.    
  165. }
  166.  
  167. class user{
  168.    
  169.     String nombre;
  170.     int ventana;
  171.     int operacion;
  172.     int time;
  173.    
  174.     user sig;
  175.  
  176. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement