Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is there any guide lines for this problem ?

 
Arad Chear
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Project 2
A printer manager program is to manage 10 printers (maximum) available in a local area network. Printer manager receives jobs from the student users. It processes a printing job by sending it to the printer that has smallest number of jobs waiting. Each printer selects print jobs to print in the following order: 1 to 2 page jobs are printed first, 3 to 5 page jobs next, any other sized job according to the time of arrival. Each student is allowed to print a maximum of 100 pages per semester. The printer manager must keep a record of this, and prevents a student who has exceeded his quota, from printing. The printer manager should also enable addition or removal of a printer; removal only if it does not have a print job waiting to be printed.

a. Give a graphical representation of the ADT.
b. Give the specification of various operations/methods of the ADT PrinterManager. The ADT should have at least the following three methods: processJob � to process a print job sent by a student for printing; addPrinter � insert or activate a new printer in the network; and removePrinter � to remove or deactivate a printer in the network. Other than these you will have to specify other supporting methods.
c. Implement the specification as a Java class.
d. Test your PrinterManager implementation by using it in the Main class where static main method reads print requests, requests to add and remove printers from a text file and calls appropriate PrinterManager methods. Assume initially there are 3 printers (ids: 1, 2, 4) active and there are 20 students registered (ids from 1 to 20). After reading the requests from the file and dispatching jobs to printers, the main method should access, each printer through a PrinterManager method, and output the details of the print jobs dispatched to it. It should also print the ids of the students who used their quota.


Please turn over�.

Test Data:
Student 2: print 20 pages
Student 11: print 50 pages
Student 12: print 30 pages
Student 1: print 2 pages
Student 11: print 40 pages
Student 1: print 1 page
Student 2: print 30 pages
Remove printer #2
Student 11: print 20 pages
Student 3: print 2 pages
Student 12: print 70 pages
Student 2: print 20 pages
Add printer #7
Student 6: print 4 pages
Student 7: print 14 pages

The output format:
Printer #1: Print job: Student Id 1: 2 pages
Print job: Student Id 2: 20 pages

Printer #2: Print job: Student Id 11: 50 pages



i don't want to answer this project , i want only guideline how can i connect student object with printer queue ,

i think maybe in HashMap but the doctor sayed no use for Maps only queues and PriorityQueue , i have try but i stop because i don't know how to link
printer and its jop , like this :
Printer #2: Print job: Student Id 11: 50 pages

i used Comporator in PQueue but it doesn't work , is there any GUIDE LINES for this problem ?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, I like the Comparator & PriortyQueue idea. What does "didn't work" mean? What did it do that wasn't what you wanted?
 
Arad Chear
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to make sure my Comparator behaviour is true ,

it print only 1 2

where is 5

this is Student class :





and this is Job class :

 
Arad Chear
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
huh ! i solve it

why this work :



and this not



really iam confusing from 5 hours ago and i deal with this problem
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm guessing because i is getting bigger and jobs.size() is getting smaller and they cross before you're done. See what while(jobs.size() > 0) does where you have for(...) now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic