dakrous 0 Newbie Poster

I am having trouble with how to print from the doubly linked class i created. I could really use some help here is my code

import java.io.*;

public class SongList
{
    private static Node head,tail;
    
    public SongList()
    {
        head = new Node();
        tail = new Node();
        
        head.setNext(tail);
        head.setPrev(null);
        
        tail.setNext(null);
        tail.setPrev(head);
    }

    public static void insert(Object item, Object item2, Node current)
    {

        
        current = new Node();
        
             current.setNext(tail);
            
             current.setPrev(head);
             
             current.setPrev(current);
             
             current.setNext(current.getNext());
             
             System.out.println("Item " + item + " "+  item2);

    }
    
    public static void delete(Node current)
    {
        current = new Node();
        
        current.setNext(current.getNext());
        current.setPrev(current.getPrev());
        System.out.println(current.getTitle());
        System.out.println(current.getArtist());
    }
     public static void print(Node current)
    {
        System.out.print("I print");
         System.out.print("No..." + current.getNext()+ "-");

        if(current == null)
        {
        System.out.println("Nothing here ");
        }
        Node n = head;
        while (n!= null)
        {
            System.out.print("No..." + current.getNext()+ "-");
            n = n.getNext();
        }
	  System.out.println();
    }

 
    public static void main(String[] args) {

String add = "add";
String remove = "remove";
String print = "print";
try 
{
String s = null;
String prompt = ">> ";
BufferedReader inData = new BufferedReader(new InputStreamReader(System.in));
System.out.print(prompt);

while ((s = inData.readLine()) != null && !s.equals("quit"))
 {
     Node doe = new Node();

     System.out.println("You entered : " + s);
if(s.equals(add))
{
String y = null;
System.out.println("Enter song title");
y = inData.readLine();
doe.setTitle(y);

System.out.println("Title" + " " + doe.getTitle());

System.out.println(" ");

String x = null;
System.out.println("Enter artist name");
x = inData.readLine();
doe.setArtist(x);
System.out.println("artist " + " " + doe.getArtist());
insert(y,x,doe.getNext());

/*Node temp = new Node(y,x,doe.getPrev(),doe.getNext());
System.out.println("Temp is" + temp.getArtist());
print(temp);*/
}
if(s.equals(remove))
{

System.out.println(" ");
String z = null;
System.out.println("Enter song title");
z = inData.readLine();
doe.setTitle(z);
System.out.println("you removed " + doe.getTitle()+ " " +
" from your playlist");

delete(doe.getNext());
System.out.println(" ");

}
if(s.equals(print))
{

System.out.println("print has " + " " + doe.getNext());
System.out.println("print has " + " " + doe.getPrev());

print(doe);
}
System.out.print(prompt);
}

}
catch (Exception e){
System.out.println(e);
}
System.exit(0);
}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.