All pastes #42669 Raw Edit

Pete B Dance Machine

public text v1 · immutable
#42669 ·published 2006-02-21 16:51 UTC
rendered paste body
public class Store

{

   // Private Data



    private Person[] list;

    private int count;        

    private int maxSize;
    private int current = 0;



   // constructor



    public Store(int max)

    {

         maxSize = max;

         list = new Person[maxSize];    

         count = 0;

    }



     // transformer



     public void add(Person p)

     {                                      

        list[count] = p;

        count ++;

     }
     
     public void incrementPointer()
	{
		if(maxSize == current)
			current = 0;
	}



   //accessors



     public boolean isFull()

     {

       return count == maxSize;           

     } 

    

     public int getCount()

     {                                    

        return count;

     }



	public Person currentRecord()
	{
		return p[current].name;
	}
	
	

     public boolean isIn(Person p)  

     {

        boolean found = false;

        int counter = 0;

        while ( counter < count & ! found)

        {

                  if (list[counter].equals(p))

                       found = true;

                  counter ++;

        }

        return found;

    

     }

    //output method



     public void displayAll()

     {

        for (int counter= 0; counter< count; counter ++)

            System.out.println(list[counter]);                 

     }



}