Monday, 24 March 2014

Creating LinkedList

So I asked Ryk to give me an example, and he created:

Main Class is called Quack (and will have to create a linked list using the list class).

Inside the List Class: 

class List {

Node head;

List()
{
head=null;
}

public void insert(String n, String p, int a, String b)
{
Node newNode = Node(n,p,a,b);

if(head==null) head=newNode;
else
{

}
}

}

Inside the Node Class: 


class Node {
String name;
String phoneNumber;
int age;
String birthday;
Node next;
Node(String n, String p, int a, String b)
{
name=n;
phoneNumber=p;
age=a;
birthday=b;
}
}

In other words, when you create a linked list thing, you have to use the "LIST" Class...

No comments:

Post a Comment