Solved

simple queue

Posted on 2002-04-28
2
263 Views
Last Modified: 2010-03-31
does anyone have any examples of a Printer queue?

where you can add , docname, owner, size and position in queue

how to add data to queue
how to remove data from queue
how to remove item from anywhere in queue
total size of queue
check to see if its empty

etc
0
Comment
Question by:penfold69
2 Comments
 
LVL 1

Accepted Solution

by:
googlyralph earned 200 total points
ID: 6976596
What about a regular queue, of Objects of type PrinterJob (or something), each PrinterJob contains the the info.

public class PrinterQueue{
protected Vector jobs = new Vector(DEFAULT_LENGTH);

public int getSize(){
return jobs.size();
}

public void addJob(PrinterJob pj){
jobs.add(pj);
}

public PritnerJob removeNext(){
   return deleteJob(0);
}

public PritnerJob deleteJob(int jobId){
   return (PrinterJob) jobs.remove(jobId);
}

public boolean isEmpty(){
   return getSize() > 0 ? false : true;
}
}

Then in PrinterJob:

public class PrinterJob{
protected String docName;
...
public String getDocName(){
return docName;
}
}

That any help?

GR.

(NOTE: that code i wrote off the top of my head, so it will need a little work to compile).
0
 
LVL 4

Expert Comment

by:pellep
ID: 6977642
You could just extends java.util.Stack. It pretty much offers the required functionality.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now