Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Arraylist implementation (do my methods make sense pt.2)

807588Mar 24 2009 — edited Mar 26 2009
m back again, m working on the array list implementation
and so far i have gotten this far, I want to know if i am going in the right direction, because i feel that something is wrong, the add method that i created for my array implementation was less complicated then the one i made for linked list, so can someone please confirm my methods.
My add method adds an element to the end of the list

Note = my project is to create a list of an integer set(unordered nonrepitative collection of integers)
public class MyArraySet<Value> implements MySet<Value> {
    private int[] Array;
    private int capacity = 65535; /* i am guessing this is the array capacity 
because the teacher told us that the range of each number in the set is
 from 0 to 65535, and since the set is non repitative 65535 would be the 
max range of the size of the set correct?*/

   public boolean isIn(Integer v){      //checks if the value is in the array
       int count=0;
       boolean flag=false;
        for(count=0; count<size(); count++)
        {
            if(Array[count]==v){
                flag=true;
                break;
            }
        }
        return flag;
    }

   public void add(Integer v){ // adds the element to the end of the list
int[] temp= new int[size()+1];
int count=0;
      temp[size-1]=v;
   }

   public int size(){ //gets the size of the list
    return Array.length;
}
this is my interface
public interface MySet<Value> {
boolean isIn(Integer v);
void add(Integer v);
void remove(Integer v);
MySet union(MySet s);
MySet intersect(MySet s);
MySet difference(MySet s);
int size();
void printSet();
}
thanks, would appreciate any comments and m new to programming so I know there are a lot of mistakes lol :)

Edited by: haraminoI on Mar 24, 2009 11:08 AM

Edited by: haraminoI on Mar 24, 2009 11:09 AM

Edited by: haraminoI on Mar 24, 2009 11:11 AM

Edited by: haraminoI on Mar 24, 2009 11:12 AM

Edited by: haraminoI on Mar 24, 2009 11:14 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 23 2009
Added on Mar 24 2009
67 comments
154 views