Solved

simple queue

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mockito example issue 8 72
Why method in Java which is called from Runnable run() doesn't need to be 'static'? 1 24
Arrays.asList  VS  ArrayList 4 54
table example 4 29
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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.

785 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