Results 1 to 2 of 2
  1. #1
    wasserbrunner is offline Member
    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Default How should I layout this program? (just to help me get a start)

    Hello. I just would like some help on how to layout a program I am working on. It's a virtual print queue.
    I have written methods for most of the major functionality, but I have never had to put together a program this complex (even though it is obviously not very complex at all).

    All I'm looking for is some sudo code basically just showing me how to organize the methods, classes, and constructors. And anything else you think I might need to know.

    Hopefully that makes sense. ANY help at all is very greatly appreciated.

    Here are the guidelines for the program:
    (it's mainly a big loop, and each time it loops is a "cycle")
    Implement a virtual print queue. A single print queue is servicing a single printer. Print requests appear periodically and print jobs can take more than one cycle on the printer to complete printing. Attached is a file which has four types of input records:

    q,3,10 is a q type record which indicates that a print job, # 3, shall be placed at the rear of the queue and print for 10 cycles when it is removed from the front of the queue and prints.

    p,4,5 is a p type record which indicates that a prioritized print job, # 4, shall be placed at the front of the queue and execute for 5 cycles when it is removed from the front of the queue and prints.

    s,5 is an s type record which indicates that 5 cycles should be executed before the next input record is examined.

    h is an h type record which indicates to halt execution of the simulation and print out the executing print job number, the number of cycles left to execute and the remaining print queue numbers and cycles in order of execution from last to first.

    A print job will decrement the number of remaining cycles at the start of a new cycle. When a job finishes (the number of remaining cycles reaches 0), a new job should be loaded on the same cycle. You must implement the queue insert and remove methods as described in the text. You must also implement a priority insert method which inserts a prioritized print job at the beginning of the queue. You must implement a stack with the push and pop methods to print the remaining queue numbers and cycles for the halt.

    here's what the input file looks like
    q,1,5
    s,3
    q,2,2
    q,3,1
    p,4,5
    s,4
    q,5,1
    q,6,1
    p,7,3
    s,4
    q,8,1
    q,9,1
    p,10,2
    p,11,1
    q,12,3
    q,13,2
    p,14,4
    s,5
    h

    and here's what he says the output should look like

    1.) if you use the sample data in the description, the queue will contain

    -empty-

    and the current print job is #13 with 2 cycles of time left,

    2.) if you change the first input record to q,1,25 then the queue will contain

    13, 2
    12, 3
    9, 1
    8, 1
    6, 1
    5, 1
    3, 1
    2, 2
    4, 5
    7, 3

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,953
    Rep Power
    19

    Default Re: How should I layout this program? (just to help me get a start)

    A lot will depend how much Java you know.
    But I would say you have 3 related classes, which each involve cycling, that is they involve continuing around the loop before grabbing the next item on the queue. So they ought to extend a parent or implement an interface whose sole purpose is to cycle, say having a decrement method and a hasFinished method?

    I'm not sure there's a massive difference between q and s types, as far as your code is concerned. The only thing is one has a state of printing I suppose.

    That should give you more than enough to see a structure.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Where should I start with this program?
    By westbakke in forum New To Java
    Replies: 3
    Last Post: 06-02-2011, 04:16 AM
  2. Replies: 1
    Last Post: 01-18-2011, 06:27 PM
  3. Need help on how to start off with a program
    By javanoobie in forum New To Java
    Replies: 6
    Last Post: 03-23-2009, 11:42 PM
  4. Replies: 5
    Last Post: 03-20-2009, 10:04 PM
  5. Really Stuck on how to Start this program
    By random0munky in forum New To Java
    Replies: 4
    Last Post: 10-29-2008, 08:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •