Results 1 to 2 of 2
- 10-17-2012, 10:03 AM #1Member
- Join Date
- Oct 2012
- Rep Power
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
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
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
- 10-17-2012, 10:55 AM #2Moderator
- Join Date
- Apr 2009
- Rep Power
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 **
- By westbakke in forum New To JavaReplies: 3Last Post: 06-02-2011, 04:16 AM
- By albertkao in forum EclipseReplies: 1Last Post: 01-18-2011, 07:27 PM
- By javanoobie in forum New To JavaReplies: 6Last Post: 03-24-2009, 12:42 AM
- By ScottVal in forum New To JavaReplies: 5Last Post: 03-20-2009, 11:04 PM
- By random0munky in forum New To JavaReplies: 4Last Post: 10-29-2008, 09:57 AM