Results 1 to 8 of 8
  1. #1
    killingvirus is offline Member
    Join Date
    May 2010
    Posts
    4
    Rep Power
    0

    Default Simulation of Print Server

    I'm trying to write a code of a simulation of a print server (it's only a simulation using GUI or Text) and I need the help of experts.

    Explanation of the simulation:

    When running the program, the user must specify how many printers are included in the program. Then the program will create an array of printers with a linked list representing the print queue.

    When the user gives a print command, the program will take the print job and sends it to the printer with the least jobs in its queue (load balancing).

    The print job must disappear from the queue after 15 seconds.


  2. #2
    Sno's Avatar
    Sno
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Posts
    195
    Rep Power
    5

    Default

    1. Ask User Input
    2. Put user input where you create the array
    3. When user gives print command, run a method that checks all arrays and find the smallest,
    4. create a timer (for loop?) than erase value in array.

    I dont really know... just a suggestion for steps!
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

  3. #3
    killingvirus is offline Member
    Join Date
    May 2010
    Posts
    4
    Rep Power
    0

    Default

    Thanks bro for the help.. but you're talking to totally illiterate beginner in Java :)
    I'm having the following problems:
    1. building a code with a loop which will create queues in the array (or jobs in the printers)
    2. creating the timer for the print jobs.

    This is what a wrote so far and i couldn't go further with this code:


    package main;

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.* ;
    import java.util.*;

    class main {
    public static void main(String[] args)
    {
    int nPrinters;
    System.out.println("Please enter the number of printers.");
    Scanner n = new Scanner(System.in);
    nPrinters = n.nextInt();
    System.out.println("Your print server has " + nPrinters);
    LinkedList[] printServer = new LinkedList[nPrinters];

    }

  4. #4
    killingvirus is offline Member
    Join Date
    May 2010
    Posts
    4
    Rep Power
    0

    Default

    can't believe this.. 110 viewers and only 1 reply?!!

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by killingvirus View Post
    can't believe this.. 110 viewers and only 1 reply?!!
    This usually is a function of the question itself: is it posed in a way to pique forum member's interest? Is the code formatted and posted using code tags so that it is easily readable? Is there enough information present so that members feel that the question is in fact answerable? Has the OP asked questions that are very specific and answerable? Has the OP shown the results of his efforts including his efforts of his debug? etc...

    As to your current thread, you may get better help by using code tags and by asking questions that are much more specific.

    For more information on how to ask questions that get answers, please have a look at the link in my signature on "how to ask smart questions"

    Much luck!
    Last edited by Fubarable; 05-15-2010 at 11:10 PM.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Also, rather than work from the main method, you might want to start from the other direction: first think what classes this project may need, what state these classes should have, and what actions and interactions. Do this well and the pieces should fall together. Again, much luck!

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by killingvirus View Post
    I'm having the following problems:
    1. building a code with a loop which will create queues in the array (or jobs in the printers)
    Since the user will be initiating the creation of print jobs, if this is being coded for a Swing GUI, no loop is needed for this since it will be events such as button presses that will initiate this action. If you are doing this in a console program, then a simple while loop may suffice (looping until the user gives some indication that they wish to quit).

    2. creating the timer for the print jobs.
    Again you should think OOP here and the print jobs should become a class in their own right, perhaps called PrintJob, and perhaps printing can be initiated by calling a print() method. Within this method I think a simple Thread.sleep(15000) will suffice as your timer. If this is being done in a Swing GUI, you'll need to take care to do this sleeping in a background thread.

    Again, much luck.

  8. #8
    killingvirus is offline Member
    Join Date
    May 2010
    Posts
    4
    Rep Power
    0

    Default

    thanks for the reply.. it really clarified the main issues..

Similar Threads

  1. Dice Simulation Program
    By touandcim in forum New To Java
    Replies: 3
    Last Post: 03-15-2010, 01:09 PM
  2. beehive simulation
    By BlueF4re in forum New To Java
    Replies: 2
    Last Post: 12-02-2009, 09:31 AM
  3. Mars Simulation Project 2.84
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 06-26-2008, 07:18 PM
  4. Pulley Simulation..HELP
    By dazza-s in forum Java 2D
    Replies: 2
    Last Post: 06-18-2008, 11:51 PM
  5. Small tennis simulation in Java
    By diego in forum New To Java
    Replies: 1
    Last Post: 12-02-2007, 02:32 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
  •