Need to use pushpop method stacks Design a generic class Col

*Need to use push-pop method (stacks)* Design a generic class, Collection, that stores a collection of Objects (in an array), along with the current size of the collection. Provide public methods isEmpty, makeEmpty, insert, remove, and isPresent. isPresent(x) returns true if and only if an Object that is equal to x (as defined by equals) is present in the collection. *Need to use push-pop method (stacks)*

Solution

public class Collection {

private Object[ ] collection;

private int size;

private int capacity;

public boolean isEmpty()

{

return (size == 0);

}

public void makeEmpty(int max)

{

}

public void insert (Object x)

{

}

public void remove (Object x)

{

}

public boolean isPresent (Object x)

{

for (int i=0; i<size; i++)

{

if (collection[i].equals(x))

return true;

}

return false;

}

}

*Need to use push-pop method (stacks)* Design a generic class, Collection, that stores a collection of Objects (in an array), along with the current size of the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site