r/programminghelp • • Nov 08 '18

Help with Linked List in Java?

Not going to lie, I'm working on a school lab, but im not surfing for solutions, just a little help.

TL;DR: How do I create a linked list of Objects and proceed to manipulate them?

Longer Version: I have five classes:

Game

Trivia extends Game

Static TriviaNode (inner class to Trivia)

Static TriviaLinkedList (inner class to Trivia)

TestTriviaGames (my test client)

It is required by the lab that I have the first four classes. I can create Trivia objects easily, but im struggling to get the objects into a linked list so I can test my methods I had to code to manipulate the list.

Im confused about the use of the TriviaNode and TriviaLinkedList classes. Are they required to actually make and use a linked list? Which class should be setting the head and tail? Should I be setting that in my test client?

4 Upvotes

2 comments sorted by

0

u/[deleted] Nov 08 '18

[deleted]

2

u/DimitriTheMad Nov 09 '18

Hey thanks! That last paragraph put me in a better frame of mind!

Obviously, im going to use my Trivia constructor to create Trivia objects, but which constructor am I going to use to create the linked list? The TriviaLinkedList constructor? If so, can I use it to create a linked list with the Trivia objects I've already made?

0

u/[deleted] Nov 09 '18

[deleted]

2

u/DimitriTheMad Nov 09 '18

You've lost me a little on the last part. I need to call the no arg TriviaLinkedList constructor inside my Trivia constructor?