예제 #1
0
 static void imprimirMapStrArray(Map<String, ArrayList<Coche>> map) {
   System.out.println("\t╓─────────────┬──────────┬────────┬─────────────┬──────────╖");
   System.out.println("\t║  Marca      │ Modelo   │ CC     │ NºCilindros │ CVFiscal ║");
   System.out.println("\t╙─────────────┴──────────┴────────┴─────────────┴──────────╜");
   for (Map.Entry<String, ArrayList<Coche>> marcaCoche : map.entrySet()) {
     System.out.println("Marca de coche: [" + marcaCoche.getKey() + "]");
     System.out.println("\t╓─────────────┬──────────┬────────┬─────────────┬──────────╖");
     for (Coche coche : marcaCoche.getValue()) {
       System.out.println(
           "\t╠► "
               + String.format("%1$-10s", coche.getMarca())
               + " │ "
               + String.format("%1$-8s", coche.getModelo())
               + " │ "
               + coche.getCilindrada()
               + "cc"
               + " │ "
               + coche.getCilindres()
               + " Cilindros"
               + " │ "
               + String.format("%1$-5s", String.format("%.2f", coche.potenciaFiscal()))
               + "CF  ║");
     }
     System.out.println("\t╙─────────────┴──────────┴────────┴─────────────┴──────────╜");
   }
 }
예제 #2
0
 static void imprimirArray(ArrayList<Coche> array) {
   System.out.println("\t┌───────────┬──────────┬─────────┬───┬──────┐");
   for (Coche coche : array) {
     System.out.println(
         "\t│"
             + String.format("%1$-10s", coche.getMarca())
             + " │ "
             + String.format("%1$-8s", coche.getModelo())
             + " │ "
             + coche.getCilindrada()
             + " cc"
             + " │ "
             + coche.getCilindres()
             + " │ "
             + String.format("%1$-5s", String.format("%.2f", coche.potenciaFiscal()))
             + "│");
   }
   System.out.println("\t└───────────┴──────────┴─────────┴───┴──────┘");
 }