title: Ready to pull my hair out Java Queues with objects
body: <p>Can anyone tell me where im going wrong I have three files Person.java Queue.java &amp; Cinema.java, ive managed to do queues without objects Person.java but. I am having trouble implementing with objects.</p>
  
  <p>Heres my Queue.java</p>
  
  <pre><code>    public class Queue
  {
      private Person[] person = new Person[10];       
      private int rear;
  
      public Queue()
      {
  
         rear = 0;                      
      }
  
      public boolean isEmpty()
      {
           return rear == 0;
      }
  
      public String remove()          //remove String element
      {
          String result = person[0].toString();       //shuffle String elements
          rear--;
          for (int i = 0; i &lt; rear ; i++)
          {
              person[i] = person[i + 1];
          }
          return result;
      }
  
      public void add(Person x)           //add String element
      {
          if (rear == person.length)
          {
              resize();
          }
          person[rear] = x;
          rear++;
      }  
  
      private void resize()
      {
          Person[] temp = new Person[person.length * 2];    //resize String array
          for (int i = 0; i &lt; person.length; i++)
          {
              temp[i] = person[i];
      }
          person = temp;
      }
  }
  </code></pre>
  
  <p>Then heres Person.java (Object).</p>
  
  <pre><code>    public class Person
  {
      private String name;
      private int age = 0;
  
      public Person(String name1, int age1)
      {
          this.name = name1;
          this.age = age1;
      }
  }
  </code></pre>
  
  <p>And heres the main java file Cinema.java</p>
  
  <pre><code>    import java.util.*;
  public class Cinema {
      public static void main (String[] args)
      {
          Queue q = new Queue();
          Scanner k = new Scanner(System.in);
          System.out.print("Enter name: ");
                  String name = k.nextLine();
                  System.out.print("Enter Age : ");
                  int age = k.nextInt();
  
                  q.add(name);
                  System.out.println(name + " joined queue");
      }
  }
  </code></pre>
  
  <p>Basically I want a person to join the queue with a name and age and the first person goes to buy the ticket and the age is checked. I can do the check bit its just getting it to read with objects.</p>
  
  <p>Thanks</p>