Solved

simple queue

Posted on 2002-04-28
2
267 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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 if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

730 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