when I create this hashMap in main an fill it in, everything works perfect
HashMap<String, Furgoneta> mapper = new HashMap<>();
LocalDate f1 = LocalDate.of(2013, Month.JANUARY, 1);
LocalDate f2 = LocalDate.of(2016, Month.FEBRUARY, 10);
Furgoneta furgo1 = new Furgoneta("0001AAA", "Seat", "Ibiza", false, f1, f2, 3100);
//FILLING HASHMAP
mapper.put(furgo1.getMatricula(), furgo1);
System.out.println(mapper.toString());
when I try to write this same code inside a class instead of main the put won't work (unable to fill hashmap)
//FILLING HASHMAP
mapper.put(furgo1.getMatricula(), furgo1);
System.out.println(mapper.toString());
object furgoneta (means van)
public class Furgoneta extends VehiculoAlquiler implements Serializable
{
private int mma;
//constructor
public Furgoneta(String matricula, String marca, String modelo, boolean alquilado,
LocalDate fechaI, LocalDate fechaF,int mma ) {
super(matricula, marca, modelo, alquilado, fechaI, fechaF);
this.mma = mma;
}
public int getMma() {
return mma;
}
if I write this main it works
HashMap<String, Furgoneta> furgonetas = new HashMap<>();
LocalDate f1 = LocalDate.of(2013, Month.JANUARY, 1);
LocalDate f2 = LocalDate.of(2016, Month.FEBRUARY, 10);
Furgoneta furgo1 = new Furgoneta("0001AAA", "Seat", "Ibiza", false, f1, f2, 3100);
//Las introducimos en la HashMap
furgonetas.put(furgo1.getMatricula(), furgo1);
System.out.println(furgonetas.toString());
furgo1.importeAlquiler(f1, f2);
but I want to do the exact same but with the hashMap inside a class not in main
I cannot fill in the hashmap I created. If the hashmap is inside main I can fill it in but if I try to write the hashmap inside a class instead of main and fill it, when i'm trying to fill it in it says "package mapper does not exist" and "package furgo1 does not exit" when mapper is meant to be the hashmap name and furgo1 an object
i cannot see my mistake, i would really appreciate some help, i been stuck here for hours. Sorry if is confusing is the first time i ask