|
01 packagepackage is used to name the directory or folder a class is in intermediate;
02 //start auto-imports
03 importimport means to make the classes and/or packages available in this program java.util.*;
04 importimport means to make the classes and/or packages available in this program java.awt.event.*;
05 //end auto-imports
06
07
08 /**
09 * All about my application.
10 * @authornull Jam Jenkins
11 */
12 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects Queue2009
13 {open braces start code blocks and must be matched with a close brace
14 privateprivate is used to restrict access to the current class only Queue<Customer2009>[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays lines;
15 privateprivate is used to restrict access to the current class only Associate[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays cashier;
16 privateprivate is used to restrict access to the current class only Timer timer;
17 privateprivate is used to restrict access to the current class only CustomerEntrance task;
18 privateprivate is used to restrict access to the current class only longlong is the type for whole numbers (they have a larger range than int) serviceTime;
19
20 publicpublic is used to indicate unrestricted access (any other class can have access) Queue2009(intint is the type for whole numbers and it is short for integer numberOfLines, longlong is the type for whole numbers (they have a larger range than int) averageInterarrivalRate, longlong is the type for whole numbers (they have a larger range than int) averageServiceTime)
21 {open braces start code blocks and must be matched with a close brace
22 serviceTime=this assignment operator makes the left side equal to the right sideaverageServiceTime;
23 lines=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Queue<Customer2009>[brackets are typically used to declare, initialize and index (indicate which element of) arraysnumberOfLines]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
24 cashier=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Associate[brackets are typically used to declare, initialize and index (indicate which element of) arraysnumberOfLines]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
25 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side0; i<lines.length; i++this is the increment operator, which increases the variable by 1)
26 {open braces start code blocks and must be matched with a close brace
27 lines[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Queue<Customer2009>();
28 cashier[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Associate(averageServiceTime);
29 }close braces end code blocks and must match an earlier open brace
30 timer=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Timer();
31 CustomerEntrance entrance=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor CustomerEntrance();
32 timer.schedule(entrance, (longlong is the type for whole numbers (they have a larger range than int))(Math.random()*averageInterarrivalRate*2));
33 }close braces end code blocks and must match an earlier open brace
34
35 classclass is a group of fields and methods used for making objects CustomerEntrance extendsextends means to customize or extend the functionality of a class TimeTask
36 {open braces start code blocks and must be matched with a close brace
37 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value actionPerformed(ActionEvent e)
38 {open braces start code blocks and must be matched with a close brace
39 Customer2009 customer=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Customer2009();
40 intint is the type for whole numbers and it is short for integer smallest=this assignment operator makes the left side equal to the right side0;
41 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side1; i<lines.length(); i++this is the increment operator, which increases the variable by 1)
42 {open braces start code blocks and must be matched with a close brace
43 ifif executes the next statement only if the condition in parenthesis evaluates to true(lines[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays.size()<lines[brackets are typically used to declare, initialize and index (indicate which element of) arrayssmallest]brackets are typically used to declare, initialize and index (indicate which element of) arrays.size())
44 {open braces start code blocks and must be matched with a close brace
45 smallest=this assignment operator makes the left side equal to the right sidei;
46 }close braces end code blocks and must match an earlier open brace
47 }close braces end code blocks and must match an earlier open brace
48 customer.joinQueue();
49 lines[brackets are typically used to declare, initialize and index (indicate which element of) arrayssmallest]brackets are typically used to declare, initialize and index (indicate which element of) arrays.add(customer);
50 ifif executes the next statement only if the condition in parenthesis evaluates to true(lines[brackets are typically used to declare, initialize and index (indicate which element of) arrayssmallest]brackets are typically used to declare, initialize and index (indicate which element of) arrays.size()==this is the comparison operator which evaluates to true if both sides are the same1)
51 {open braces start code blocks and must be matched with a close brace
52 customer.startService();
53 longlong is the type for whole numbers (they have a larger range than int) timeToServe=this assignment operator makes the left side equal to the right side(longlong is the type for whole numbers (they have a larger range than int))(2*Math.random()*serviceTime);
54 timer.schedule(newnew is used to create objects by calling the constructor Service(smallest), timeToServe);
55 }close braces end code blocks and must match an earlier open brace
56 }close braces end code blocks and must match an earlier open brace
57 }close braces end code blocks and must match an earlier open brace
58
59 classclass is a group of fields and methods used for making objects Service extendsextends means to customize or extend the functionality of a class TimerTask
60 {open braces start code blocks and must be matched with a close brace
61 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer index;
62
63 publicpublic is used to indicate unrestricted access (any other class can have access) Service(intint is the type for whole numbers and it is short for integer i)
64 {open braces start code blocks and must be matched with a close brace
65 index=this assignment operator makes the left side equal to the right sidei;
66 }close braces end code blocks and must match an earlier open brace
67
68 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value actionPerformed(ActionEvent e)
69 {open braces start code blocks and must be matched with a close brace
70 Customer customer=this assignment operator makes the left side equal to the right sidelines[brackets are typically used to declare, initialize and index (indicate which element of) arraysindex]brackets are typically used to declare, initialize and index (indicate which element of) arrays.remove();
71 customer.finishService();
72 ifif executes the next statement only if the condition in parenthesis evaluates to true(lines[brackets are typically used to declare, initialize and index (indicate which element of) arraysindex]brackets are typically used to declare, initialize and index (indicate which element of) arrays.size()>0)
73 {open braces start code blocks and must be matched with a close brace
74 longlong is the type for whole numbers (they have a larger range than int) timeToServe=this assignment operator makes the left side equal to the right side(longlong is the type for whole numbers (they have a larger range than int))(2*Math.random()*serviceTime);
75 timer.schedule(newnew is used to create objects by calling the constructor Service(smallest), timeToServe);
76 schedule(thisthis means the current object (the implicit parameter), timeToServe);
77 }close braces end code blocks and must match an earlier open brace
78 }close braces end code blocks and must match an earlier open brace
79 }close braces end code blocks and must match an earlier open brace
80
81 publicpublic is used to indicate unrestricted access (any other class can have access) staticstatic means that an instance is not required for access (class level access) voidvoid means the method does not return a value mainThe main method is the place where applications begin executing.(String[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays args)
82 {open braces start code blocks and must be matched with a close brace
83 System.out.println("Hello JavaWIDE!");
84 }close braces end code blocks and must match an earlier open brace
85 }close braces end code blocks and must match an earlier open brace
|