Copec 3 interfaz

PHOTO EMBED

Wed Dec 20 2023 13:01:23 GMT+0000 (Coordinated Universal Time)

Saved by @javcaves

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/**
 *
 * @author clemente
 */
public class Copec {
    //la copec es de un lugar y tiene surtidores y empleados
    public String direccion;
    public Surtidor[] surtidores;
    public Empleado[] empleados;
    //creamos una nueva copec
    public Copec(String direccion) {
        surtidores=new Surtidor[6];
        for(int i=0; i < surtidores.length; i++)
           surtidores[i]=new Surtidor(i);
        empleados=new Empleado[2];
        for(int i=0; i < empleados.length; i++)
           empleados[i]=new Empleado(i);
          
    }
    //el empleado e, echa en a, la cantidad del surtidor
    public void echar(int e,Auto a,int cantidad,int s) {
        surtidores[s].echarGasolina(empleados[e], cantidad,a);
    }
    //imprime la informacion de surtidores
    @Override
    public String toString() {
        String cadena="";
        for(int i=0; i < surtidores.length; i++) {
            cadena+=surtidores[i].toString();
            //cadena+="\n";
        }
        return cadena;
    }
    
    public void guardarInfoCSV() {
        try(FileWriter fw = new FileWriter("copec.csv", true);
            BufferedWriter bw = new BufferedWriter(fw);
            PrintWriter out = new PrintWriter(bw)) {
            
            out.println(toString());
           
        } catch (IOException e) {
    
        }   
    }
    
}import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/**
 *
 * @author clemente
 */
public class Copec {
    //la copec es de un lugar y tiene surtidores y empleados
    public String direccion;
    public Surtidor[] surtidores;
    public Empleado[] empleados;
    //creamos una nueva copec
    public Copec(String direccion) {
        surtidores=new Surtidor[6];
        for(int i=0; i < surtidores.length; i++)
           surtidores[i]=new Surtidor(i);
        empleados=new Empleado[2];
        for(int i=0; i < empleados.length; i++)
           empleados[i]=new Empleado(i);
          
    }
    //el empleado e, echa en a, la cantidad del surtidor
    public void echar(int e,Auto a,int cantidad,int s) {
        surtidores[s].echarGasolina(empleados[e], cantidad,a);
    }
    //imprime la informacion de surtidores
    @Override
    public String toString() {
        String cadena="";
        for(int i=0; i < surtidores.length; i++) {
            cadena+=surtidores[i].toString();
            //cadena+="\n";
        }
        return cadena;
    }
    
    public void guardarInfoCSV() {
        try(FileWriter fw = new FileWriter("copec.csv", true);
            BufferedWriter bw = new BufferedWriter(fw);
            PrintWriter out = new PrintWriter(bw)) {
            
            out.println(toString());
           
        } catch (IOException e) {
    
        }   
    }
    
}
content_copyCOPY