so i have to create my own linked list. i cannot use the onethat java provides.
ID: 3613760 • Letter: S
Question
so i have to create my own linked list. i cannot use the onethat java provides. i have to insert multiple values in eachsectionso each section will have a first and a last name of a person
a specific time that was given through an input file
a ticket number
a meal plan
then i will have to continue to add people to this list with thesessame items.
i dont really know where to start. as in i dont know how tospecifically create a linked list. my book has examples of circulardoubly and single list and i dont know the best for my problem.some of the people in the list may have to be put before others inthe list at any time. i have to delete people from this listwhich i can do by changing the ending pointers of the nodes. So do i have to create a whole nother class file for the linkedlist or can it be done in a function. what would each of these haveto contain in them.
Explanation / Answer
Creating another class for the personal data will solve yourproblem. class Pdata { public String firstName; publicString lastname; public double time; public int ticketnumber; public String mealPlan; public Pdata( String fn, String ln, double t,int tn, String mp) { this.firstName = fn; this.lastName = ln; this.time = t; this. ticketNumber = tn; this.mealPlan = mp; } //you can as well implement get, set methods forthis Pdata class } //end of pdata class public class LList { //declare whatever you want /// attributes, function //declare LinkedL:ist as shown below LinkedList ll = newLinkedList(); //for adding data you can use the belowmethod ll.add(new Pdata("harry", "potter", 12, 1234,"Dinner")); }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.