Question: 1 . In the driver, exercise twelve various insersion and deletion operations. 2 . If duplication is found for inserion, the program provides a message,
In the driver, exercise twelve various insersion and deletion operations.
If duplication is found for inserion, the program provides a message, and does not insert duplicated magzine.
If no title is found in deletion operation, the program provides a message, and does not delete any magazin.
Code:
public class MagazineList
private MagazineNode list;
Sets up an initially empty list of magazines.
public MagazineList
list null;
Creates a new MagazineNode object and adds it to the
end of
the linked list.
public void addMagazine mag
MagazineNode node new MagazineNodemag;
MagazineNode current;
if list null
list node;
else
current list;
while currentnext null
current current.next;
current.next node;
Returns this list of magazines as a string.
public String toString
String result ;
MagazineNode current list;
while current null
result current.magazine
;
current current.next;
return result;
An inner class that represents a node in the magazine
list.
The public variables are accessed by the MagazineList
class.
private class MagazineNode
public Magazine magazine;
public MagazineNode next;
Sets up the node
public MagazineNodeMagazine mag
magazine mag;
next null;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
