+3 Jacob Fellows · December 6, 2014
Hi there,
I'm struggling with my assignment on queues that is to create a program that creates a print queue and am allowed to use any method such as a linked list, dequeue or the queue<E> function. I would rather use the queue function as it seems simple.
I have attached the java class code I have done so far and I am learning to use these code boxes as well.

The java class code:
package bobsyouruncleassignment2;
import java.util.*;
 * @author Jacob
public class DeQueCode
{ //Start of class
    int fileSize;
    private String fileName;
    private String userID;
    private UUID printerID;
    *This is the constructor of the JavaDoc for my program
    * It is used to create a new print job.
    *@param fileSize is the file size
    *@param fileName is the file name
    *@param userID is the user Identification
    * @param printerID is the identification for the printer
    public DeQueCode(int fileSize, String fileName, String userID, UUID printerID)
    { //The word *this.* means set the value in the instance of a print job
        this.fileSize = fileSize;
        this.fileName = fileName;
        this.userID = userID;
        this.printerID = printerID;
    } //End of the constructor
    //Now to the methods that are going to be used in my program
    //Starting with the getters
     * Gets the file name
    public int getFileSize()
        return this.fileSize;
     * Gets the last name
      public String getFileName()
        return this.fileName;
     * Gets the telephone number
        public String getUserID()
        return this.userID;
        *Gets the printer ID.
        public UUID getPrinterID()
            return this.printerID;
        //Now the setters
         * Sets the print job for the file size
         * @param fs file size of the print job
    public void setFileSize (int fs)
        this.fileSize = fs;
         * Sets the print job for the file name
         * @param fn file name of print job
       public void setFileName (String fn)
        this.fileName = fn;
         * Sets the print jobs user name
         * @param ui user ID for the print job
       public void setUserID (String ui)
        this.userID = ui;
        * Sets the print job a random printer ID
        * @param
       public void setPrinterID (UUID pi)
           this.printerID = pi;
       //Finally the toString method to show all the print jobs info
     public String toString()
         return ("File sizee: " + fileSize + "\n"
                 + "File name:" + fileName + "\n"
                 + "User ID: " + userID + "\n"
                 + "Printer ID: " + printerID);
} //End of class

I would like to then make the program itself have a few option choices such as the code below that will go along with the above.
    public static void main(String[] args) {
    Queue q = new Queue(); //Queue of size 5
    int ch;
    Scanner sc =new Scanner(;
    System.out.println("Enter choice :");
        case 1:
            System.out.println("Enter data to insert");
        int x=sc.nextInt();
        case 2:
            System.out.println("Queue underflow");
                int z =q.delete();
                System.out.println("data deleted =" + z );
        case 3: q.display();
        case 4: q.destroy();
        case 5: break;
        default : System.out.println("Wrong Choice");

Please help and all the help is greatly appreciated from you guys as you seem to know stuff better than I do and I would love to become part of your java crew.
Thanks again,
P.S If you do help me Santa will be very happy with you this year! :) LOL

Post a Reply


- page 2
Oldest  Newest  Rating
0 Jacob Fellows · December 9, 2014
Hi there, I found the code online and wanted to do something similar and wanted to change it to make it function the way I want it too. I struggle with programming and I don't enjoy it because my lecturer seems to be doing things in a very odd order. Such as in my first assignment we were meant to use javadocs comments and I didn't get it and then two weeks ago we learn about it.

Also the code is to be used for a print job. The UUID is a way of creating a unique identifier for the printer ID.

Here is where I got the code from:

I just thought I would change it so that it makes sense for the program in mind. Also I am using the scanner so that it can take inputs and display outputs in the same box.

1. I am not aware of what the ad.set, ad.get or ad.add are.
2. I need to organise the switch to match the block of methods you can do in the program. maybe move them around so that they work good.
3. The Boolean is used as a true or false statement and probably be changed to an if statement or something so that it works. Also if the array is 0 then it means that it is empty and needs data to be inputted from the user.
4. Also in the java class there needs to be a method for adding a instance of the object, setting the head and tail of the array queue, display the array deque with all the values inputted into it and a way to clear the data from the array deque.

Thanks for the help my dude! It boosts my spirits and makes me feel as if I need to do something nice for you.

0 Developer John · December 9, 2014
Lol, no problem. I usually help people with their code lots of times outside these forums. I'm sorry for saying this, but I don't think it's a great idea copying code. I feel like it's better to make your own unique program so that someone gets ideas from you instead. When I copy someone's code, I feel like I don't know what I'm doing, or I'm just bored lol.:sideways:
0 Jacob Fellows · December 9, 2014
Hi There Developer John,

I thought you were going to be my little helper but I guess not. I have spent hours trying to find an example of the sort of code that I needed for the assignment so that I could use it as an example and make sure that I build the correct way. So yeah, I need the help and expertise of someone that has more java knowledge than me. I will always try to help others out and have found this site to be better at responding to a thread or post that someone has created over whirlpool and many like it. I also prefer this forum because we can have fun and see what people need help with.

Thanks from a tired, worried student named Jacob.
0 Developer John · December 9, 2014
Lol, now you sound desperate. I never really said I was giving up, I just wanted to share my thoughts on this. So, shall we continue?:sideways:
0 Developer John · December 10, 2014
Okay, I understand. So, how exactly do you want to change this program? Have you had much experience with Queues in Java lately?;)
0 Developer John · December 7, 2014
You'll learn your mistake.
0 Developer John · December 15, 2014
I'm sorry as well. Even though I was brave enough responding here, I felt bad no one could help. I'm not even close to hitting Java Intermediate yet because I'm understanding all the rules of methods, constructors, and even classes. I want to soak up enough information as I can in order to help people here on the forums. Without help, the forums would be dead. Once I hit Java Intermediate and get to the Queue tutorial, I'll look up all the documentation for them and even go through Oracle tutorials for them. The only way I helped you was trying to tell you what I knew you could easily fix.

-Have A Great Christmas! 

0 Developer John · December 7, 2014
I'll try to help you lel:
1. Importing many classes in a Java program could result in some lag issues down the road
2. When doing:
System.out.println("Welcome to the Print Job Program\n");

The \n is unnecessary, because println goes to the next line after printing out something, but only do this when printing out one primitive datatype or variable.
3. When you close the program, why not use an if statement to check if the user input is equal to "y"? Right after that, you could make a statement where the Scanner closes:

4. I don't know why, but I'm having a hard time trying to figure out what you want this program to do next.
0 Jacob Fellows · December 11, 2014
Hi there,

The assignment is meant to be in by 11pm UK time tonight so I am going to just use code I already have and manipulate it so that it works. I haven't used an array deque before and I have looked into how a normal queue works. I would still like the help though.

I would like to manipulate the code so that it allows the user to add a document name. file size, user ID and printer ID.

Thanks from a stupid student named Jacob.
0 Developer John · December 11, 2014
Okay, first off, you're not stupid. Your resources are on this site btw. Tutorial 15 in Java Intermediate will help you with queues, and tutorials 78-81 will help you with your file problem.

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator