• Post Reply Bookmark Topic Watch Topic
  • New Topic

Test Cases  RSS feed

 
courtney young
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again, I've been trying to come up with some test cases for this class but for some reason can't get anything to work. I've tried



and it keeps giving me the error: The method push(int) is undefined for the type
SinglyLinkedList<Integer> (But I don't understand why it is saying its undefined)

 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your push method takes a Node as its parameter, not an AnyType E.

As you have been told before, use single‑letter names for your formal type parameters.
Your push method is implemented incorrectly. I am also not convinced it runs in constant time. It will run in constant time but is dependent on your using a linked list rather than any other kind of list.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please remove some of those comments from your code; they are not helpful. Also please space things correctly: 1 blank line before each method but no need for blanks just before the end of the method.

Actually you want to call the push method on your stack object not your list object.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!