Solved

simple queue

Posted on 2002-04-28
2
268 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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

734 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