Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There are multiple pictures. The code is the first part and is included. public class Model Edata; Node next publie Mode element) data elements next

There are multiple pictures. The code is the first part and is included.
image text in transcribed
image text in transcribed
image text in transcribed
public class Model Edata; Node next publie Mode element) data elements next sull; public String tostring return String.value this.data) > > public void add(nt Index, element) Node tempi-head; while(index>0) tenpl-templ.net Node tempnew lodeelement); temp.next-templ.next templ.nextstep: public void addrests element) Node temp new Hodetelement) af (headell) tail tempi temp.next-head; ) puble vaid addat menent Node temp new lode (element) if(taill) tail temps headtemp: else tail.next-temp tasteten > > puble I getic return head.data: publie B getest return tail.data: public void remove(int Index) Node temp-head) while --Index>0) tempi compl.next; templ.next-templ.next.sext; publie renoverite E datahead.datai head-head. next return data: publie renovelastot data-tail.datai Node tempehead while temp.nextI-tail) tenpetemp.nexts temp. next null; Lasieten: retorn datat public int size int count Node temp-head: whileftenplanunt (temp temp.next; count++1 return count public String tostring Node temp heads string stre" while temp.nextlenull) atrate temp.data." tempetemp.next atstritep.data return str 1 > Second, you must create your own test program named ListTestYourName Your test program will runs with sential loop with user input. The main menu will be similar as follows. --Linked List Test Program-- 0 - Exit Program 1 - Add First Node 2- Add Last Node 3 - Add at Index 4 - Remove First Node 5- Remove Last Node 6 - Remove at Index 7 - Print List Size Select option: + user input here Test each method at least one execution for each, then show the status before & after execution with proper label. Except for options 0 and 7 above, when calling a method on the list make sure the method prints the list content before and after executing the called method, For example, the output of testing method removeLasto) would be displayed like this (assuming the list has 10, 20, 30, 40, 50): Testing method remove LastNode() List content before removing last node is: 10 20 30 40 List content after removing last node is: 10 20 30 40 50 User choose remove option but there is no element in the List, you need to show the message like this List is Empty now. Again, you cannot change method names, return type and parameter types

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Be familiar with the integrative servicescape model.

Answered: 1 week ago

Question

Determine the roles of spatial layout and functionality.

Answered: 1 week ago