Forums Register Login

Double Linked List error message

+Pie Number of slices to send: Send
I am trying to work on a DoubleLinkedList code and ran into a few errors I couldn't fix.
The error I am getting is for DoubleLinkedList.java and is on the 4th line: (I could be doing my whole code wrong but I am only getting this 1 error. I would appreciate any help or feedback. I have not coded in java in so long so I'm very rusty.

DoubleLinkedList.java:4: lists.DoubleLinkedList is not abstract and does not override abstract method size() in lists.CustomList
public class DoubleLinkedList<T extends Comparable<T>> implements CustomList {
^
1 error

My codes:

MAIN


CustomList.java


DoubleNode.java

DoubleLinkedList.java
+Pie Number of slices to send: Send
 

Maria Macalino wrote:My codes:...


Maria,

Please don't put very long lines inside code blocks (see the UseCodeTags page). It screws up the windowing here and makes things hard to read.
I've broken up a few of those long comments for you, but please remember in future.

Thanks.

Winston

PS: I also removed some redundant blank lines. Smaller usually == better.
+Pie Number of slices to send: Send
Please don't create duplicate threads
+Pie Number of slices to send: Send
So, where is your size() method? You wrote in your interface that there would be a size() method, but you haven’t written one.

Suggestion
  • 1: You have a private static int size field in your node class.
  • 2: Your add() insert() etc methods all include the statement size++;
  • 3: Your remove() delete() or excise() methods similarly include size--;
  • 4: You now know what to return from the size() method.
  • 5: This technique may not work correctly if you have two lists simultaneously; the size() method will probably return the sum of their sizes
  • 6: You now know enough to solve that last problem.
  • +Pie Number of slices to send: Send
    Don’t use /*...*/ to comment out blocks of code. Use // on each line. If there are any /**..*/ or /*..*/ comments in the block you are trying to comment out, only // will work reliably. Also, don’t quote commented‑out code here unless there is a specific problem in it which you want us to read.
    +Pie Number of slices to send: Send
     

    Sumit Patil wrote:Please don't create duplicate threads

    That other thread is probably not a duplicate, but thank you for noticing.
    +Pie Number of slices to send: Send
    Thank you all for your posts. Sorry about the incorrect format. I am new here and I promise to make it shorter in the future and I'll fix the comments in the future.

    I haven't finished writing the rest of my code because I wanted to see if it would compile as is first before I keep going. I'm trying to get rid of that error first.
    +Pie Number of slices to send: Send
    Despite the regular good advice on here to write only a few lines at a time before compiling, this isn't possible when you are writing a non-abstract class that implements an interface. You have to implement all the interface's methods before it will compile. A common approach in such cases is to have each of the methods throw an UnsupportedOperationException until you get round to doing the proper implementation.
    +Pie Number of slices to send: Send
    You can always write stub methodsThat will keep the compiler happy. Or, you can try what NetBeans does
    +Pie Number of slices to send: Send
     

    Maria Macalino wrote:Thank you all for your posts. Sorry about the incorrect format. I am new here and I promise to make it shorter in the future and I'll fix the comments in the future.


    No probs. It's more for you, because it makes your posts easier to read.

    Winston
    This will take every ounce of my mental strength! All for a tiny ad:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 1092 times.
    Similar Threads
    compiler will not accept setprev or getprev to make doubly linked listin
    Java Linked List
    RefList help
    Reversing a Linked List
    different ways to implement singly linked list
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 28, 2024 11:13:54.