Advertisement
fmbalvarez

Lector villero

Apr 29th, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.94 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class Lector {
  5.    
  6.     Scanner scanner;
  7.     List<String> lineasTxt = new ArrayList<String>();
  8.    
  9.    
  10.     public Lector() throws IOException{
  11.         this.leer();
  12.     }
  13.    
  14.     public void leer() throws IOException{
  15.         scanner = new Scanner(new File("/Users/felipealvarez/Downloads/prueba.txt"));
  16.         while(scanner.hasNextLine()){
  17.             String lineaLeida = scanner.nextLine();
  18.             lineasTxt.add(lineaLeida);
  19.         }
  20.     }
  21.    
  22.     public int getTiempoLavadoEconomico() throws IOException{
  23.         int tiempo = 0;
  24.         StringTokenizer tokenizer = new StringTokenizer(lineasTxt.get(1),",");
  25.         List<String> tokens = new ArrayList<String>();
  26.         while(tokenizer.hasMoreTokens()){
  27.             tokens.add(tokenizer.nextToken());
  28.         }
  29.        
  30.         tiempo += Integer.parseInt(tokens.get(0));
  31.        
  32.         tokenizer = new StringTokenizer(lineasTxt.get(2),",");
  33.         tokens = new ArrayList<String>();
  34.         while(tokenizer.hasMoreTokens()){
  35.             tokens.add(tokenizer.nextToken());
  36.         }
  37.        
  38.         tiempo+= Integer.parseInt(tokens.get(0));
  39.        
  40.         return tiempo;
  41.     }
  42.    
  43.     public int getCostoLavadoEconomico() throws IOException{
  44.         int costo = 0;
  45.         StringTokenizer tokenizer = new StringTokenizer(lineasTxt.get(1),",");
  46.         List<String> tokens = new ArrayList<String>();
  47.         while(tokenizer.hasMoreTokens()){
  48.             tokens.add(tokenizer.nextToken());
  49.         }
  50.        
  51.         costo += Integer.parseInt(tokens.get(1));
  52.        
  53.         tokenizer = new StringTokenizer(lineasTxt.get(2),",");
  54.         tokens = new ArrayList<String>();
  55.         while(tokenizer.hasMoreTokens()){
  56.             tokens.add(tokenizer.nextToken());
  57.         }
  58.        
  59.         costo += Integer.parseInt(tokens.get(1));
  60.        
  61.         return costo;
  62.     }
  63.  
  64. }
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73. import java.io.IOException;
  74. import java.util.*;
  75.  
  76. public class ListaDeLavados{
  77.    
  78.     Lector lector;
  79.    
  80.     LinkedList <Lavado> lista = new LinkedList <Lavado>();
  81.    
  82.     public ListaDeLavados() throws IOException{
  83.         Lavado lavadoEconomico = new Lavado (lector.getTiempoLavadoEconomico(), lector.getCostoLavadoEconomico(),"x");
  84.  
  85.     }
  86.    
  87.    
  88.    
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement