FOR GAHGUY ONLY ..

profileMesfer almesfer
azz.zip

PA3.docx

In hw1, we helped Jacks Mart develop a simple checkout system. That system was so successful that they've decided to expand their operations by opening additional checkout lanes. Unfortunately, they are unsure of just how many lanes they need to add. Ideally, Jacks Mart would add enough lanes to satisfy expected demand. However, opening too many lanes would mean that they're paying checkers to staff empty lanes. Your goal is to develop a checkout lane simulation that can be used to determine the optimal number of lanes that Jacks Mart should have open.

Your program should simulate an entire day at Jacks Mart. For this simulation, we will assume that Jacks Mart is open 12 hours (720 minutes) a day. As this is a simulation, you don't actually need to run your program for 12 hours. Instead, consider the time span to be an integer, with each minute being a number. As such, 0 would indicate the start of the simulation, 1 would represent the first minute of the simulation, 2 the second minute, and so on.

Program Flow

Your simulation should operate as follows:

1. Prompt the user for the number of checkstands to simulate

2. Create a data structure that contains the appropriate number of checkstands

3. Set the probability of a new customer arriving equal to 0.

4. For each minute in the simulation

a. Determine if a new customer has arrived.

i. Generate a random number between 0 and 5.

ii. If the random number is less than or equal to the probability of a new customer arriving (Step #3), reset the probability back to 0 and go to Step 4.B.

iii. If the number is greater than the probability of a new customer arriving (Step #3), increment the probability of the new customer arriving by 1. Go to Step 4.C.

b. If a new customer has arrived, create a new customer whose arrival time is equal to the current simulation time and whose service time is a randomly generated number between 1 and 4. Next, try to find an empty checkstand. If one exists, place the customer in the line at that checkstand. If no empty checkstand exists, randomly select a checkstand for the customer to enter.

c. For each checkstand in the simulation:

i. If there is at least one customer in the checkstand, go to 4.C.II. Otherwise, go back to 4.C (look at the next checkstand in the simulation).

ii. If the first customer in line has not received a departure time, calculate one. Departure time = current tick + service time.

iii. If the total time elapsed is greater than the first customer's departure time, then the customer has completed the checkout process. Remove them from the queue.

d. Increment the elapsed time in the simulation

5. After the simulation completes, write the results to a CSV file in the following format: <Customer ID>, <Arrival Time>, <Time to Check Out>, <Departure Time>, <Total Wait>, <Line Number>. Also include the total number of customers generated during the simulation at the top of the CSV file. Note that an example CSV file will be included with this assignment description. I have provided a CsvWriter class to aid in the construction of CSV files.

Required Bits

I'm going to leave more of the design decisions up to you, however, at minimum, your program must use a vector or linked list to store the collection of checkstands. Additionally, each individual checkstand must represent its line of customers using a queue. You may either use the data structures developed in class or those provided to you by the STL.

Optional Bits

For those wanting a bit more direction, my simulation contains two additional classes:

Customer

I use the customer class to contain details about individual customers. Here's the UML diagram:

As you can see, I have private member variables to track all of the customer's information. Note that I have a static integer called "_id_counter" that ensure that each customer receives a unique customer ID number. Each time that I create a new customer, I increment that number. Related to this is the static method generateCustomer(). I use this method to create all my customers, sort of like you would when using a Factory. I also have a method that computes the total wait time, which is simply the arrival time subtracted from the departure time. Finally, I have all the typical getters and setters for my member variables that you would expect.

CheckoutLine

I use CheckoutLine to represent a single checkstand in my simulation. Here's the UML diagram:

Note that each CheckoutLine has a line name. This is so that we can determine what lines serviced which customers when examining the final CSV output file. Also note that each CheckoutLine keeps track of the total minutes, which I call "ticks" (a common term in computer science). Each time the tick() method is called, I increment the _ticks variable. Also, the tick() method is responsible for performing checkstand-specific tasks listed in section 4.C of the simulation algorithm. As part of that method, I move the customers that have finished the checkout process from "_line" into "_serviced_customers", which I use when creating my CSV file. Here's a breakdown of the other methods in this class:

isEmpty

Returns true if our "_line" queue is empty

addCustomer

Adds the supplied customer to our "_line" queue of customers

getServicedCustomers

Returns a reference to our vector of serviced customers. To be used when creating the final CSV file.

Sample Output

Below is a screenshot from my program. Note that while you are free to create your own internal implementation, your program must conform to the output below.

Header Comment, and Formatting

1. Be sure to modify the file header comment at the top of your script to indicate your name, student ID, completion time, and the names of any individuals that you collaborated with on the assignment.

2. Remember to follow the basic coding style guide. A basic list of rules is included with this document.

Deliverables

You must upload your program and reflection as a ZIP file through the site no later than midnight on THURSDAY, October 6, 2016. Remember that your submission must either contain a CodeBlocks or Visual Studio project file!

Reflection Essay

In addition to the programming tasks listed above, your submission must include an essay that reflects on your experiences with this homework. This essay must be at least 350 words long. Note that the focus of this paper should be on your reflection, not on structure (e.g. introductory paragraph, conclusion, etc.). The essay is graded on content (i.e. it shows deep though) rather than syntax (e.g. spelling) and structure. Below are some prompts that can be used to get you thinking. Feel free to use these or to make up your own.

· Describe a particular struggle that you overcame when working on this programming assignment.

· Conversely, describe an issue with your assignment that you were unable to resolve.

· Provide advice to a future student on how he or she might succeed on this assignment.

1. Describe the most fun aspect of the assignment.

1. Describe the most challenging aspect of the assignment.

1. Describe the most difficult aspect of the assignment to understand.

1. Provide any suggestions for improving the assignment in the future.

Grading Criteria

Your assignment will be judged by the following criteria. Note that the points for each category will be normalized to be 100%.

Error Free Compile (weight: 5pts)

· [0] Your program contains compiler errors.

· [1] Your program compiles without issue.

Error Free Runtime (weight: 5pts)

· [0] Your program throws a runtime exception.

· [1] Your program does not encounter any runtime exceptions.

Pointer Cleanup (weight: 5pts)

· [0] Your program does not delete any dynamically-created pointers

· [1] Your program remembers to delete some, but not all dynamically-created pointers

· [2] Your program deletes all dynamically-created pointers

Style (weight: 10pts)

· [0] Your program does not contain good style. Variables are poorly named, your program doesn't contain a header, there is little or no documentation, your document isn't properly formatted (indentation, whitespace, etc.), and is generally hard to read.

· [1] Your program contains suboptimal style. Some of the items listed in the [0] section are accounted for

· [2] Your program contains good style. Most of the items listed in the [0] section are accounted for.

· [3] Your program contains excellent style. Almost everything in listed in the [0] section is accounted for.

Implementation (weight: 20pts)

· [0-3] Your program's implementation is inefficient. Class usage is non-existent, your code has a lot of redundancy, and is generally not up to the standards of what is expected of a CptS 122 student.

· [4-6] Your program's implementation is acceptable, but can be improved upon. You may use classes, but they are used poorly. Likewise, some redundancy must exist.

· [7-10] Your program's implementation is exemplar. Classes are used in thoughtful and meaningful ways. There is little, if any, redundancy. If this were kindergarten, you would receive a gold star.

User Interface (weight: 5pts)

· [0] Your program does not even attempt to follow the UI guidelines

· [1] Your program's UI has major inconsistencies when compared to the sample output

· [2] Your program's UI has minor inconsistencies when compared to the sample output

· [3] Your program completely matches the specified user interface guidelines

CSV Correctness (weight: 10pts)

· [0] Your program does not event attempt to create a CSV file

· [1] Your program creates a CSV file but it is corrupted or unreadable

· [2] Your program creates a readable CSV file, but certain data points are missing

· [3] Your program creates a CSV file in the expected format.

Data Structure Usage (weight : 10pts)

· [0-1] Your program uses little to no data structures.

· [2-3] Your program uses the STL data structures or the custom data structures developed in class.

Simulation Algorithm Correctness (weight: 30pts)

· [0-2] You do not implement the simulation algorithm as described in this document

· [3-4] Your algorithm implementation differs significantly from the implementation described in this document

· [5-6] Your algorithm mostly follows the implementation listed in this document, but is lacking a few key components

· [7-8] Your algorithm faithfully implements the supplied simulation algorithm.

Reflection Essay (weight: 10pts)

· [0-10] Your reflection essay meets the requirements specified previously in this document.

sample output.csv

Customers Created: 293
Customer ID Arrival Time to Check Out Departure Total Wait Line Number
0 1 4 5 4 0
5 17 1 18 1 0
9 25 3 28 3 0
10 26 3 32 6 0
16 39 2 41 2 0
19 46 1 47 1 0
21 51 3 54 3 0
22 54 2 57 3 0
23 58 3 61 3 0
24 61 4 66 5 0
28 70 2 72 2 0
30 73 2 75 2 0
31 76 3 79 3 0
39 93 3 96 3 0
40 97 4 101 4 0
42 104 4 108 4 0
43 105 1 110 5 0
46 111 3 114 3 0
48 115 4 119 4 0
56 133 3 136 3 0
58 140 3 143 3 0
59 141 4 148 7 0
60 143 4 153 10 0
61 144 1 155 11 0
62 147 4 160 13 0
63 149 3 164 15 0
64 153 1 166 13 0
65 154 3 170 16 0
70 169 3 174 5 0
71 172 2 177 5 0
72 175 2 180 5 0
73 179 2 183 4 0
74 180 2 186 6 0
78 190 3 193 3 0
79 191 3 197 6 0
82 199 1 200 1 0
84 203 3 206 3 0
85 204 1 208 4 0
88 212 3 215 3 0
89 215 2 218 3 0
90 218 4 223 5 0
93 223 3 227 4 0
95 227 2 230 3 0
96 228 4 235 7 0
97 231 1 237 6 0
102 244 1 245 1 0
103 246 2 248 2 0
104 248 4 253 5 0
105 250 1 255 5 0
106 253 3 259 6 0
107 254 4 264 10 0
108 255 3 268 13 0
110 260 3 272 12 0
111 262 1 274 12 0
112 264 3 278 14 0
114 272 2 281 9 0
115 274 2 284 10 0
119 284 3 288 4 0
122 295 2 297 2 0
124 298 3 301 3 0
125 302 2 304 2 0
127 308 2 310 2 0
129 312 4 316 4 0
130 314 3 320 6 0
131 315 2 323 8 0
133 320 2 326 6 0
135 327 4 331 4 0
136 328 1 333 5 0
139 336 4 340 4 0
142 344 2 346 2 0
143 346 4 351 5 0
144 350 1 353 3 0
145 353 1 355 2 0
147 358 4 362 4 0
151 371 1 372 1 0
153 376 4 380 4 0
155 381 2 383 2 0
156 384 1 385 1 0
161 393 2 395 2 0
162 395 1 397 2 0
163 396 4 402 6 0
164 397 3 406 9 0
167 401 4 411 10 0
169 408 3 415 7 0
170 412 3 419 7 0
171 414 4 424 10 0
173 418 2 427 9 0
177 427 4 432 5 0
179 435 4 439 4 0
180 436 4 444 8 0
182 440 1 446 6 0
185 447 4 451 4 0
187 450 2 454 4 0
189 457 3 460 3 0
191 463 3 466 3 0
192 466 1 468 2 0
196 475 3 478 3 0
197 478 3 482 4 0
200 485 3 488 3 0
201 487 1 490 3 0
203 494 2 496 2 0
204 498 3 501 3 0
206 505 2 507 2 0
207 507 2 510 3 0
208 509 4 515 6 0
209 511 4 520 9 0
211 515 1 522 7 0
213 522 1 524 2 0
216 528 2 530 2 0
218 533 3 536 3 0
219 535 3 540 5 0
221 539 3 544 5 0
222 540 2 547 7 0
227 553 2 555 2 0
228 556 2 558 2 0
229 559 2 561 2 0
230 562 2 564 2 0
231 566 3 569 3 0
232 569 3 573 4 0
233 572 2 576 4 0
234 573 2 579 6 0
236 577 1 581 4 0
238 582 3 585 3 0
239 585 2 588 3 0
240 589 1 590 1 0
243 599 3 602 3 0
244 602 3 606 4 0
245 606 2 609 3 0
247 611 1 612 1 0
249 614 4 618 4 0
251 619 4 623 4 0
252 623 2 626 3 0
253 624 1 628 4 0
255 629 3 632 3 0
258 636 3 639 3 0
259 640 2 642 2 0
260 643 4 647 4 0
262 650 3 653 3 0
265 658 2 660 2 0
266 661 3 664 3 0
267 662 1 666 4 0
271 670 4 674 4 0
273 674 4 679 5 0
274 677 1 681 4 0
276 681 4 686 5 0
277 682 3 690 8 0
278 684 3 694 10 0
279 687 3 698 11 0
282 694 2 701 7 0
285 702 1 703 1 0
1 3 3 6 3 1
2 5 2 9 4 1
3 10 1 11 1 1
4 12 3 15 3 1
6 19 4 23 4 1
7 20 4 28 8 1
8 23 1 30 7 1
11 29 3 34 5 1
12 32 4 39 7 1
13 33 4 44 11 1
14 34 2 47 13 1
15 36 2 50 14 1
17 41 2 53 12 1
18 44 3 57 13 1
20 50 3 61 11 1
25 63 3 66 3 1
26 65 2 69 4 1
27 67 3 73 6 1
29 71 2 76 5 1
32 80 4 84 4 1
33 81 1 86 5 1
34 83 1 88 5 1
35 85 4 93 8 1
36 88 2 96 8 1
37 90 2 99 9 1
38 91 1 101 10 1
41 102 4 106 4 1
44 106 1 108 2 1
45 109 3 112 3 1
47 114 1 115 1 1
49 118 2 120 2 1
50 119 1 122 3 1
51 123 1 124 1 1
52 124 1 126 2 1
53 126 2 129 3 1
54 129 4 134 5 1
55 132 1 136 4 1
57 137 3 140 3 1
66 156 2 158 2 1
67 159 1 160 1 1
68 163 1 164 1 1
69 166 3 169 3 1
75 184 4 188 4 1
76 185 2 191 6 1
77 186 3 195 9 1
80 194 1 197 3 1
81 196 2 200 4 1
83 201 1 202 1 1
86 207 3 210 3 1
87 210 1 212 2 1
91 220 3 223 3 1
92 221 3 227 6 1
94 225 3 231 6 1
98 234 4 238 4 1
99 237 1 240 3 1
100 239 1 242 3 1
101 241 4 247 6 1
109 257 3 260 3 1
113 269 3 272 3 1
116 277 1 278 1 1
117 279 1 280 1 1
118 282 1 283 1 1
120 289 1 290 1 1
121 292 1 293 1 1
123 297 4 301 4 1
126 305 3 308 3 1
128 311 1 312 1 1
132 318 1 319 1 1
134 323 2 325 2 1
137 331 2 333 2 1
138 333 4 338 5 1
140 340 2 342 2 1
141 342 2 345 3 1
146 355 2 357 2 1
148 362 1 363 1 1
149 365 1 366 1 1
150 367 1 368 1 1
152 373 2 375 2 1
154 379 4 383 4 1
157 387 4 391 4 1
158 388 2 394 6 1
159 389 3 398 9 1
160 392 2 401 9 1
165 398 1 403 5 1
166 400 3 407 7 1
168 406 4 412 6 1
172 415 4 419 4 1
174 421 1 422 1 1
175 423 1 424 1 1
176 426 1 427 1 1
178 431 4 435 4 1
181 437 4 441 4 1
183 441 3 445 4 1
184 445 4 450 5 1
186 448 4 455 7 1
188 454 2 458 4 1
190 460 2 462 2 1
193 469 2 471 2 1
194 470 3 475 5 1
195 472 2 478 6 1
198 480 3 483 3 1
199 483 3 487 4 1
202 491 3 494 3 1
205 503 1 504 1 1
210 513 4 517 4 1
212 518 3 521 3 1
214 524 4 528 4 1
215 525 2 531 6 1
217 530 3 535 5 1
220 537 2 539 2 1
223 542 2 544 2 1
224 546 1 547 1 1
225 550 3 553 3 1
226 552 2 556 4 1
235 575 3 578 3 1
237 581 1 582 1 1
241 593 3 596 3 1
242 597 4 601 4 1
246 607 3 610 3 1
248 612 1 613 1 1
250 616 1 617 1 1
254 626 4 630 4 1
256 632 3 635 3 1
257 633 4 640 7 1
261 647 1 648 1 1
263 653 2 655 2 1
264 655 4 660 5 1
268 663 1 664 1 1
269 666 2 668 2 1
270 669 2 671 2 1
272 673 3 676 3 1
275 678 1 679 1 1
280 690 2 692 2 1
281 692 3 696 4 1
283 696 1 698 2 1
284 700 1 701 1 1
286 703 3 706 3 1
287 707 1 708 1 1
288 712 4 716 4 1
289 713 1 718 5 1

pa3 (2).vsdx

Queue<T> <<Stereotype>> parameter +getFirst() : T& +enqueue(item : const T&) : void +dequeue() : T Customer <<Stereotype>> parameter -_customer_id : int -_arrival_time : int -_service_time : int -_departure_time : int -_id_counter : int -_line_name : string +generateCustomer(arrival_time : int, line_name : string) +getTotalWaitTime() : int <appropriate getters and setters for private member variables> CheckoutLine <<Stereotype>> parameter -_line_name : string -_tick_count : int -_line : Queue<Customer> -_served_customers : Vector<Customer> +getLineName() : string +isEmpty() : bool +addCustomer(some_customer : Customer) : void +getServicedCustomers() : Vector<Customer> & +tick() : void