/* Programmer’s name: Julie Ann Pabio
Name of Program: Queue implementation
Date Started: March 9, 2009
Date Finished : March 12, 2009
Instructor : Mr. Dony Dongiapon
Course: IT 123: Data Structures
Objective: To be able to make a program that implements a queue data structure in a linked list
Concept: List of BSIT enrollee
//declaring a constructor
class Queue{
public int entrynum;
public String firstname;
public String lastname;
public char middlename;
public Queue next;
public Queue (int Enum, String Fname String Lname char M, )
{
entrynum=Enum;
firstname=Fname;
lastname=Lname;
middlename=M;
}
//displaying the elements on the list
public void displayQueue()
{
System.out.print(entrynum +” “ + firstname +” “ +” “middlename+ “ “ +: + lastname)
}
}
/*a separate class which contains the methods of the data structure Queue implemented in a linked list*/
class QueueList
private Queue first;
private Queue last;
public QueueList()
{
first=null;
last=null;
}
//checking if the list has elements or not
public Boolean isEmpty()
{
return (first==null);
}
//inserting an element on the queue
public void Enqueue(int Enum, String Fname String Lname char M, )
{
Queue newQueue= new Queue (int Enum, String Fname String Lname char M, )
if( isEmpty())
last = newQueue;
newQueue.next=first;
first=newQueue;
}
//Deleting an element on the queue
public void Dequeue (int Enum)
{
Queue newQueue=new Queue (Enum);
int temp=first.entrynum;
if (first.next==null)
last=null;
first=first.next;
return temp
}
}
public class MainClass {
public static void main(String[] args) {
LinkQueue theQueue = new LinkQueue();
theQueue.enqueue(001, “Marjorie”, “Egot” , ‘T’, )
theQueue.enqueue(002, “Chrisdyll”, “Pellejo”, ‘P’)
System.out.println(theQueue);
theQueue.enqueue(003, “Julie”, “Pabio”, ‘L’)
System.out.println(theQueue)
theQueue.dequeue(001);
System.out.println(theQueue);
System.out.println(theQueue);
}
}
JUL wla lge ka ng ingon sa amo nka buhat nka? Copy nlang me ha unta dli ka masuko, kay ingon man gud ka wla pka kahimo, kay mutabang unta me pero ok lang SALAMAT kay nka buhat nka..... TNX U TNX U TNX U KAU>>>>>>>.... . .
ReplyDeleteklasm8, pwd copy nlng q sa imo ghimo....
ReplyDeletetenchu!!!!
r!co>>>>>>