title: Two instance variables in the class of a one dimensional array
body: <p>I'm hoping someone can help me out with a question that I've been stuck on for quite a while.</p>
  <p>Just to clarify the scenario. There is a show being held in a theatre that can hold 180 people. They allow online bookings that are written to a text file &quot;bookings.txt&quot; Individual bookings are single that only have a seat, contact and payment status record. Whereas group bookings have seats, a contact number, payment status, group name and group size records.</p>
  <p>So far I have created the Bookings and GroupBookings classes. I'll show them below:</p>
  <pre><code>/**
   *
   * @author OP
   */
  public class Booking 
  {
      public String seat;
      public String contact;
      public double cost;
      public boolean paid;
      
      //Constructor
      public Booking(String st, String ct, int cost, boolean pd)
      {
          seat = st;
          contact = ct;
          this.cost = cost;
          paid = pd;
      }//end of Booking
      
      //Getters
      public String getSeat() 
      {
          return seat;
      }//end of getSeat
  
      public String getContact() 
      {
          return contact;
      }//end of getContact
  
      public boolean isPaid() 
      {
          return paid;
      }//end of isPaid
      
      public double getCost()
      {
          //Determining what discount should be applied to their seat location
          if (seat.contains(&quot;A&quot;) || seat.contains(&quot;B&quot;) || 
              seat.contains(&quot;C&quot;) || seat.contains(&quot;D&quot;))
          {
              cost = 200;
          }
          else
          {
              if (seat.contains(&quot;E&quot;) || seat.contains(&quot;F&quot;) || 
                  seat.contains(&quot;G&quot;) || seat.contains(&quot;H&quot;))
              {
                  cost = 160;
              }
              else
              {
                  if (seat.contains(&quot;I&quot;) || seat.contains(&quot;J&quot;) || 
                      seat.contains(&quot;K&quot;) || seat.contains(&quot;L&quot;))
                  {
                      cost = 120;
                  }
              }
          }//end of nested if statement
          return cost;
      }//end of getCost
      
      @Override
      public String toString()
      {
          return seat + &quot;\t&quot; + &quot;R&quot; + cost + &quot;\t&quot; + paid;
      }//end of toString
      
  }//end of class booking
  </code></pre>
  <pre><code>/**
   *
   * @author OP
   */
  public class GroupBooking extends Booking
  {
      private String groupName;
      private int groupSize;
      
      public GroupBooking(String st, String ct, boolean pd, String gn, int gs)
      {
          //Variables from previous class (using inheritance)
          super.seat = st;
          super.contact = ct;
          super.paid = pd;
          
          //New variables for this class
          groupName = gn;
          groupSize = gs;
      }//end of GroupBooking
      
      @Override
      public double getCost()
      {
          cost = super.getCost();
          
          for (int i = 0; groupSize % 4 &gt; i; i++)
          {
              cost = cost - 60;
              i++;
          }//end of for loop
          
          return cost;
      }//end of getCost
      
      public int getGroupSize()
      {
          return groupSize;
      }//end of getGroupSize
      
      public String getGroupName()
      {
          return groupName;
      }//end of getGroupName
      
      @Override
      public String toString()
      {
          return seat + &quot;\t&quot; + &quot;R&quot; + cost + &quot;\t&quot; + groupName;
      }//end of toString
  }//end of class GroupBooking
  </code></pre>
  <p>Now for the question that I am stuck on:</p>
  <p>A new class has to be created called BookingManager. From there I have to declare two instance variables in the class of one-dimensional array that can be used to store up to 180 Booking or GroupBooking objects. An integer counter must also be created to keep track of how many Bookings are stored in the array. (These two instance variables should not be accessible from outside the class)</p>
  <p>I'm still a newbie in coding and I'm unsure of what to do here. The follow-up question is also giving me difficulties:</p>
  <p>A contractor then has to be created to read the information from the text file &quot;bookings.txt&quot;. Each line either contains a single Booking or a GroupBooking object. Read each line from the file and instantiate the appropriate type of object (Booking or GroupBooking) and add it to the array. (Note in the case of GroupBooking you must create an object in the array for each member of the group. Exp for a group of six you have to have six separate GroupBooking objects in the array.)</p>
  <p>I know a file scanner is needed from the second question but I have no idea whether to use a for loop or an if statement to differentiate between a single booking or a group booking.</p>
  <p>If anyone can help I would truly appreciate it. This topic is still very new to me.</p>