Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

simple queue

Posted on 2002-04-28
2
Medium Priority
?
271 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 600 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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.
Suggested Courses

670 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