I've defined an object and then created numerous objects from a filescanner. I've done this by having a while loop keep adding these objects into an ArrayList to store them for later use.
I'm now trying to print out said object as a string, the issue I'm finding is it has various attributes (int, string, double, boolean, boolean, boolean).
Below is the object:
class Room {
int roomNumber;
String roomType;
double roomPrice;
boolean roomBalcony;
boolean roomLounge;
boolean roomReserved;
public Room(int roomNumber, String roomType, double roomPrice, boolean roomBalcony, boolean roomLounge, boolean roomReserved) {
this.roomNumber = roomNumber;
this.roomType = roomType;
this.roomPrice = roomPrice;
this.roomBalcony = roomBalcony;
this.roomLounge = roomLounge;
this.roomReserved = roomReserved;
}
This is the scanner.
while(file.hasNextLine()){
int roomNumber = file.nextInt();
String roomType = file.next();
double roomPrice = file.nextDouble();
boolean roomBalcony = file.nextBoolean();
boolean roomLounge = file.nextBoolean();
boolean roomReserved = false;
rooms.add(new Room(roomNumber, roomType, roomPrice, roomBalcony, roomLounge, roomReserved));
file.nextLine();}
file.close();