Queue Class


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Queue Class

Threaded View

  1. #1
    Join Date
    Dec 2004
    Posts
    12

    Queue Class

    Hi,

    I would like to develop a StringQueue class to hold a queue of String objects.
    I am not exactly sure how I would go about doing this.

    I have created a StringList class which looks something like this:

    Code:
    public class StringList
    {
        // attributes
        private String[] list;
        private int total;
        
        // methods
        public StringList (int sizeIn)
        {  
            list = new String [sizeIn];
            total = 0;
        }
    
    
        public boolean add(String s)
        {   
            if(!isFull())
            {
                list[total] = s;
                total++;
                return true;
            }
            else
            {
                return false;
            }
        }
        
        public boolean isEmpty(
        {
            if(total==0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        
        public boolean isFull()
        {
            if(total==list.length)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        
        public String getItem (int i)
        {
            return list [i-1];
        }
        
        public int getTotal()
        {
            return total;
        }
        
        public boolean remove (int numberIn)
        {
            // to be completed
        }
    }
    Any suggestion would be appreciated

    Thanks
    Last edited by Inzaghi; 03-15-2005 at 06:17 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center