Assignment Linked List Help

R

roubir

Can some please implement a class called MyList to finish this off?

public class MyList<E extends Comparable<E>> extends List<E> {

}

----------------------------------------------------------------------------------------------------
It must be implemented with this List.java:

public abstract class List<E extends Comparable<E>> {

protected class Node<T extends Comparable<T>> {

protected Node(T data) {

this.data = data;
}

protected T data;
protected Node<T> next;
}

public abstract void insert(int index, E data) throws ListException;

public boolean isEmpty() { return head == null; }

public abstract E remove(int index) throws ListException;

public void reverse() { head = reverse(head, null); }
protected abstract Node<E> reverse(Node<E> curr, Node<E> prev);

public abstract int search(E data) throws ListException;

public int size() { return size; }

protected Node<E> head;
protected int size;
}

I need help for this assignment ......

Thanks...
 
A

Alex Hunsley

roubir said:
Can some please implement a class called MyList to finish this off?

No. Stop being lazy. Why deprive yourself of an education? Why bother
with classes if you're not even going to do the work?
 
O

Oliver Wong

roubir said:
Can some please implement a class called MyList to finish this off?

public class MyList<E extends Comparable<E>> extends List<E> {

}

----------------------------------------------------------------------------------------------------
It must be implemented with this List.java:
[code snipped]

I need help for this assignment ......

There's a difference between helping you and doing the work for you.
Many of us on this newsgroup are willing to do the former, but few are
willing to do the latter. What you could do is try to implement the methods
yourself, and if you don't get the results you expected, post the code you
have, what output you got, and what output you expected, and we'll try to
help you find the source of the bug.

- Oliver
 
J

jmcgill

roubir said:
Can some please implement a class called MyList to finish this off?
I need help for this assignment ......


Well you did say "please"... But there are a couple of really sad
things about your post. The first is that you apparently have a
professor who isn't plugged into the community enough that he reads
comp.lang.java.programmer. The second is that you tried to enter this
community by simply posting your homework assignment and asking
(politely) for someone to do it for you.

Oh well, let me get this straight. You're expected to implement this,
and you are not yet at a level where you can do it in your sleep -- it's
a very simple assignement -- but they are already throwing the generic
argument stuff at you?

Maybe you can still save face and show that you made some effort to start.

Here, I'll tell you where to start. Instead of trying to write the java
functions for remove, reverse, and search, why don't you sit down and
describe in words, what you would do to make these functions work.
If you can do that, the coding should be very simple.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top