I'm trying to read stored values from a file into an ArrayList, problem is that every value is assigned correctly to its object except one that is somehow being applied to every other object in the list. Code section looks like this
while(k<size) {
int skiper=7*k;
Float troubleshooting=0.0f;
try {
troubleshooting= Float.valueOf(Files.readAllLines(Paths.get("src/Reserva/datos.txt")).get(4+skiper));
}catch(NumberFormatException e){
troubleshooting=0.0f;
}
if(troubleshooting!=0.0f) {
String reservation1 = Files.readAllLines(Paths.get("src/Reservation/data.txt")).get((1+skiper));
String reservation2 = Files.readAllLines(Paths.get("src/Reservation/data.txt")).get((2+skiper));
String reservation3 = Files.readAllLines(Paths.get("src/Reservation/data.txt")).get((3+skiper));
Float fee = Float.valueOf(Files.readAllLines(Paths.get("src/Reservation/data.txt")).get((4+skiper)));
String reservation4 = Files.readAllLines(Paths.get("src/Reservation/data.txt")).get((5+sskiper));
int ubi=Integer.valueOf(reservation4);
listareservas.set(ubi-1,new Booking(reservation1,reservation2,reservation3,reservation4,fee));
System.out.println(reservationlist.get(k).getfee());
}
Data is stored vertically in separated lines like this
-name -date1 -date2 -fee -room -price -reservationcode
booking looks like this
public class Booking {
private static float fee;
private String nroom;
private static String initialdate;
private static String finaldate;
private String customername;
private static float price;
private String code;
private String firstname;
public Booking(String name,String indate, String findate, String roomn,float fe) {
String[]namevector= name.split(" ");
customername=name;
firstname=namevector[0];
initialdate=indate;
fechafinal=indate;
nroom=roomn;
fee=fe;
price=time.fee(initialdate, finaldate, fee);
code=namevector[0]+roomn;
every value is stored correctly, but the fee of the last element is assigned to every other object in the ArrayList.
For example:
fee1=4000
fee2=5000 after the while ends fee1=5000 and everything happens after the while ends, so I know that the problem is inside this block.