HELP! JAVA CLASS, QUEUES And Scanners

+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
       @Override
     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.in);
    do
    {
    System.out.println("Menu\n1.insert\n2,delete\n3.display\n4.destroy\n5.exit\n");
    System.out.println("Enter choice :");
    ch=sc.nextInt();
    switch(ch)
    {
        case 1:
            System.out.println("Enter data to insert");
        int x=sc.nextInt();
        q.insert(x);
        break;
        case 2:
            if(q.empty())
            System.out.println("Queue underflow");
            else
            {
                int z =q.delete();
                System.out.println("data deleted =" + z );
            }
            break;
        case 3: q.display();
            break;
        case 4: q.destroy();
            break;
        case 5: break;
        default : System.out.println("Wrong Choice");
    }
    }while(ch!=5);
    }
   
}

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,
Jacob.
P.S If you do help me Santa will be very happy with you this year! :) LOL

Post a Reply

Replies

- page 3
Oldest  Newest  Rating
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.
0 Developer John · December 12, 2014
How did it go? I'm guessing not well.:(
+1 Jacob Fellows · December 15, 2014
Hi there,

It didn't go well and I was kind of hoping for more help rather than a list of resources to go look at. I was hoping for help as in putting our minds together and thinking of a solution to my problem one step at a time. The program I built runs and displays the first message and then a referral message to the end of January.

I think I am going to email the course leader tomorrow to see if I can sit with him and ask him for the help I need and to see if there is anything we can do together to get me back up and running with my mind set so that I love java and will give it a shot in the barrel if I have too.

The reason I was wanting help is that I struggle to have any kind of inspiration or something to look forward too after I have done this course, my head isn't in the right place at the moment and I suffer in silence from bad personal mistakes and decisions.

Thanks for trying to be helpful I really appreciate it and would like you to help me out in future with any problems I have. Hopefully you can help me understand it with examples of code that I could use.

On a positive note have a great Christmas and new year!!! Also look out for a post from me when you are not busy with family over Christmas as I may need help.

Thanks from a tired out and needing to be inspired student,
Jacob.

PS sorry for not replying so soon busy with other assignments!
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! 

-Thanks!8-)
+1 Jacob Fellows · December 16, 2014
Fair play to you. Many people look at these forums and don't help out people if they need it and that is what really annoys me as I have used another forum site called whirlpool and the forums are really dead on that site as people don't want to help each other.

Anyways have a Great Christmas!!!

Thanks!!!8-)

Java / Android Development

107,207 followers
About

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

Links
Moderators
Bucky Roberts Administrator