I have been given the passenger list with passengers names, which represents the passengers currently waiting in the waiting room (which is an array).
Currently, I am struggling with some parts of step 1. The pseudocode is as follows:
- Read in the passengers.dat file into the waitingRoom array.
Here is my code:
    public class TrainStation {
    int WAITING_ROOM_CAPACITY = 30;
       static Passenger[] waitingRoom = new Passenger[WAITING_ROOM_CAPACITY]; 
       static PassengerQueue queue = new PassengerQueue();
       public static void main(String[] args) throws IOException {
       //1. 
            try {
            File pointFile = new File ("passenger.dat");
            Scanner pointReader = new Scanner (pointFile);
            String firstName, surname;
            int i = 0;
            while (pointReader.hasNext()) {
                firstName = pointReader.next();
                surname = pointReader.next();
                Passenger Object = new Passenger(firstName, surname);
                waitingRoom[i] = Object;
                i++;
            }   
                for (int fori=0; fori<WAITING_ROOM_CAPACITY; fori++){
                System.out.println(waitingRoom[fori]); }
            pointReader.close();
          } catch (IOException e) {
            System.out.println("Sorry, file not found");  
          }
My WAITING_ROOM_CAPACITY can only hold 30 passengers I created two arrays. One array is for the waitingRoom and the other one for the trainQueue. I tried to read the file using the Scanner and following the pseudocode by converting the Passenger class into an object, however, I keep getting "example.Passenger@6bc7c054" rather than reading the actual names of the passengers from the file.
In addition to this, I have two classes:
package trainstation;
public class Passenger {
    private String firstName; 
    private String surname;
    private int secondsInQueue;
    Passenger(String firstName, String surname) {
        this.firstName = firstName;
        this.surname = surname; 
        secondsInQueue = 0;
    }
This is my Passenger Class, where I allow within my add method to add a passenger with their names and surnames.
Could someone please help as I am really struggling.
 
    