 They changed it from just record to record to the cloud. So I didn't see it. Okay. So let's do a quick review of What we had here So we have stacks. This is last week What is life? Oh, somebody know I remember what that yeah Last in first out which is also the way by the way that hiring works Last person who got hired is the first person to get fired there. There's a cheerful thought to start the morning with And so we have this stack here. We represented we've had the bottom of the stack at the top and We have a choice. We have the top at the last index Or we have the top at the first index over here So a question is do you remember which one we decided to choose and why? When we did when we implemented it or when the book implemented it. Yeah Top at the last index and the reason being the ad method is what? That's right. We were using an array list and a rayless ad and remove at the end specifically how efficient it is Namely if we have the top at the last index then both the removal and addition are order one But if we put the top at the first index then we have order in Now the person who's using the stack doesn't care how we did it. That's part of the abstraction But we care because we would like this to be as efficient as possible So that's why we put the top at the last index and now the next thing we're going to be looking at today is a Q where it's a FIFO which stands for first in first out and Think of it when you go to a restaurant you're standing in line Yeah, you have an entry point people go into the line at an entry point and they leave at an exit point So if I were to add something to this Q It would go and at the entry point and now I've got two people standing in line and then when the restaurant has a place available They exit and they go into they can exit the line and go into the restaurant okay, there's something we see all the time and Now I'm just making it more formal and say oh, yeah, we we see it. We experiencing it, but let's Let's be specific about it And then here We have this so if I were to get people leaving the line There would be a 64 would go out first then 82 then 17 and then 59 So the first person that entered the 64 is going to be the first one to exit and So question is doing all the entry and exit the answer is no The entry point is usually called either the tail of the queue or the rear of the queue or the back and The exit point is usually called either the head or the front and you'll see mix and match for all of these Sometimes you'll see front and rear front and back But when Java has a remember the collections framework They have something called a queue already and they use head and tail. So that's what I'm gonna use Not my preference preference, but let's go with what Java says So things go in at the tail of the queue and they exit at the head and here are the operations that we want to be able to do on our queue and Why these are just first of all, they're hard to spell and they're hard to type but again, we're stuck with this terminology So when I want to in queue something that means I'm gonna add something and I have to tell what item it is It'll add an item and this will modify the queue DQ will remove the item at the head and return it which also modifies the queue Sometimes I want to see what's at the head of the queue, but don't modify it. I just want to look at it without removing it Just the same way we had that on a stack Running to see what was on the top of the stack without removing it. It's a useful operation We also want to find out if a queue is empty And we want to find the number of items in the queue So these are basic queue operations and the question is how efficient are these? Well, first of all, the question is how are we going to represent it and we're going to represent the tail of the queue as the first item in the ArrayList And the last item in the ArrayList is going to be the head of the queue And this is just a unilateral decision that we've made And now with a stack we had order of one because we're only operating on one side of it Now that we're operating on both ends of the ArrayList We don't have a choice. One of them is going to be order one. One of them is going to be order n And even if we were to reverse the order then we just reverse which one's order one and which one's order n so we can't win on this one Unfortunately The reason I'm deciding to in the book also decides to put the head at the end is because then the code is more consistent between stack and queue So in this case to in queue an item if I want to add something else here at the first entry point then everybody has to be pushed over to the right Dequeuing is order one and then peak emptiness and size are all order one operations Is everybody clear on why that is? Yes? And that's all I had to say about that. So let's look at the actual code for implementing a queue Is this font size large enough or do you need it larger? Everybody care for that font size? Okay, looks small to me. I don't know. Maybe maybe maybe my eyes are getting old or something Yeah It's nice to put documentation in here so whoever is reading this next is going to be able to figure out. Oh that yeah, that's what's going on So we're gonna have the tail of the queue at the beginning the head is the last item To create a new one will just create a new array list of again, this is going to be generic That way we can have queues of integers queues of strings queues of whatever we want and that's going to come up really important later today We'll use the is empty method on the array list And return whatever that is to in queue an item we add the item at position zero Speaking of which remember that we have if I have let's say array list I can say the list dot add of law and I can also say the list dot add of five So I can give a position if I don't say anything it gets added to the last item If I give a position then it'll be added at that position and everything else gets pushed to the right Question just to remind everybody about their Java What is it called when I have two different to assuming Methods with the same name but different number and type of parameters There's there's a word for what that is it begins with the letter O overloading correct So so add is an overloaded method Yes, I should put that into my notes here Okay, back to queues doesn't matter So we're using the overloaded version of add so we can add things at position zero And then we're going to remove the item at the head of the queue and return it But if you're trying to dequeue something from an empty queue Then we'll give you no such element exception And this is going to be the message that you get when the program blows out Otherwise if it's not empty we remove from the array list the last item And then peak is exactly the same only different We're using a get here because get will access the value without returning it Whatever they seem without removing it it'll rich it better return it otherwise. What's the point And then again our size of the queue will reflect the size of the array list And then the question is okay, how do I convert it to a string And I'm adding the words tail and head Otherwise when it's empty I'll return an empty queue And I guess it might be useful to so let's do a queue demo And this will be Demonstrates some of the methods of the queue That's not much of a case So the question is how are we that's the purpose of this And so the first thing we're going to do is we're going to say let's make a queue of string And let's call it states is going to be a new queue of string You can repeat the type if you want to you don't have to And now I'm going to say states dot well first of all let's do this Let's check to see that it actually does the right thing Let's compile this first And let's run it Okay, cool An empty queue really is empty that's nice to know So now let's say states dot and q California States dot and q Oh, I don't know Nevada And states dot and q Now let's take a look at what we get after we add these three things And so California came in first so it's at the head Nevada came behind it and Illinois is taking it Looking up the last position now we can say string my state becomes states dot dq And then we can print out the result After de queuing my state There's a python taking over there And yeah this line is just a little bit too long I keep seeing a lot of that by the way people having Gigantically long lines which means everybody has a really good monitor that can display like 130 characters across But when I look at the programs I don't want to have to scroll left and right so Okay, let's see what happens after we dequeue this And there we are Now the question is what happens if I wanted to empty the queue out completely No matter how big it is what would I do how would how could I do that This is an interesting little problem I wonder if it's going to need a loop correct is everybody completely confused about what I want to do yeah Let's say the what's another way of saying empty the queue let's put this way as long as there is something in the queue Dequeue it And print it out Okay, does that help Okay, so what kind of a loop are we going to need We're definitely going to need a while loop And we're going to have to have some condition here And so what are we going to do we're going to say string I don't know the The state let's call it Is going to be states that the queue So what is this condition going to be Okay, so is not empty so we have an is empty right How do I say I want it to be not empty Remember what the operator is for doing the not X Pardon Exclamation point So as long as the states is not empty I'm going to dequeue it and this and let's just add a few more things here Okay, so I have five and then I'll dequeue California Because that was the first thing that came in and then I'll Dequeue all the rest Oh, that's interesting Oh, by the way, if you catch me making a mistake like this point it out right away Okay Remember is empty below is an instance method and I need to give it an instance of a queue Otherwise it otherwise it won't work And so I dequeued California and then Nevada Illinois Delaware New Jersey So the it's in exactly the same order as which they entered Unlike a stack which is the reverse order and a queue is the same order And just for the heck of it, let's do this Let's do a system that out Let's check to see that it gives us an error There's no use even printing it out and sure enough there we got our message queue is empty Because we tried to dequeue an empty queue And I'll comment that out because I like to leave a program in a working condition But again, I'm going to upload all this when we're done And then we can You can look at it and play with it Is everybody okay with the idea of how the queue is working? Do you need me to show the output of this again? Would that help? Okay, let me run it again Like this here I forgot to hold on Let me get rid of the compiler Or the execution error, there we go So there's the code on the left and on the right you can see the results Things enter the queue at the tail And they leave the queue At the head Now the question is well what can we use these for That's interesting We know we can use stacks for something useful We can use it for anything that needs to be remembered and reversed Like the history of changes that you've made to an image in that one program Or if you wanted to say what's your history in the browser So that when I'm here in the browser And pull this out Oh well Let's go to this Here's a list of all the stuff that I've visited And again the stack is perfect for that We also use queues when we want to do a simulation And this is going to be an introduction to the kind of thing you're going to be doing on the group project And in fact let's look at the book here real quick I'm going to skip over this page here Where they have a simulation of a kids game where you pass something along And whoever ends up with it leaves the game And you keep passing it around until everybody is gone except one person It's a fun little simulation But what I want to do is I want to do something similar to this simulation of a printing task And I'm going to go over this Yeah should I go over this quickly I think it would be a good idea So here what we have is we have a bunch of computers And they have one printer in the computer lab So what's going to happen is every time somebody at the computer One of these computers wants to print something They're going to have to get in line waiting for the printer to become available Is that very, yeah So we're going to have multiple tasks sitting here waiting for a printer to become available to us And that's called a print queue This is a very, very big thing in computer science Almost all operating systems use queues to keep track of tasks that have to be done When you have a limited resource that can handle only one thing at a time You want to make sure that people get to it in order that they came in And now the question is how do we model this situation So we have to make some presumptions We say well first of all the printing is going to be from one to 20 pages in length And it's going to be sort of random Yeah how many people, some people are going to print only one page Some people may print 20 some people may print eight pages You never know so that's going to be a random variable So every time somebody enters the queue they're going to say how many pages they want to print Then the question is okay how often are people going to enter the queue So let's say there are 20 print tasks per hour on the average And that means there's going to be one task every 180 seconds So every second that goes by will generate a random number between 1 and 180 And if it comes out to 180 that means okay that was the 1 and 180 chance And so we're going to generate a new task And it'll randomly happen Now sometimes we'll have 180 seconds go by and nobody enters because we never generated that number But if we're going for a simulation for three or four hours We're eventually going to get some tasks entering our queue We're going to have a queue of print tasks And what we're going to do for each task we're going to give a time stamp So every time it arrives we're going to just have a counter That counts how many times our internal clock has ticked So we're going to have a little consent type We're going to have an integer that's going to keep track of how many seconds have passed And when a new queue enters the task we're going to say okay what does this counter say And that's going to be how many seconds have elapsed since the beginning of our simulation So every second that goes by we're going to ask did we have a new task That's our random number between 1 and 180 If so we're going to add it to the queue and it's going to say this is when it entered If the printer is not busy and there is a task because there might not be anybody in the queue So the printer is not busy it's just idols We're going to remove the next task from the print queue and assign it to the printer And then we're going to subtract the time stamp from the current second To compute how long as we want to know how long people are waiting in the queue But that's the part I didn't say again Well we want to be able to find out his statistics like for example how long is the printer in use We also want to say is okay how long are people waiting in line Okay that's very useful to know Then we might need to get a faster printer or we might need to restrict the number of pages so that people can't print as many pages And that will speed up the queue significantly But we don't know until we do the simulation Then we append the waiting time to the task for a list for later processing And then based on the number of pages we figure out how much time will be required Then we say okay now the printer is going to print for one second And we're going to subtract one second from the time required for the task And finally if that task has been completed then the printer is not busy anymore and it can handle the next thing in the queue if there is one And then we can compute how long everything has been waiting on average And what they're going to have is they're going to have the task which is the job that people wanted print and the printer And then we're going to have a queue of tasks called the print queue And we can put all the classes in the same file And that will be print simulation And then we know how to do random numbers And we're also going to need the list of waiting times That's going to be just an ordinary old array And the code is here And you can look at that but what I want to do is I want to develop something similar to that So here's what I want to work on today And what I'm going to do is I'm going to go up until lab time And then at lab time I may have to spill over into I'd like to complete that today but I'm not sure I can do it in 20 minutes So either I can do it on Wednesday Or I can spill over into lab time Take some of that and get it more complete And get it at least started And then during lab time because how many of you all still have to do the stacks assignment I'm still working on it Okay, you all can work on that then So here's the simulation that we're going to do In a clothing store We have one line of people Waiting to go into a fitting room And here's the difference Instead of just having one printer We have multiple fitting rooms Now the question is What do things look like in a clothing store In terms of What things are we going to have to simulate Well the first thing we need to do is How many people are Coming in per hour to try on clothes Okay, we're going to need the fitting rooms You know it would be even before that Before that it would be really nice to have multiple fitting rooms Before that Before that it would be really nice to know How many fitting rooms do we have And now this is how many people are coming in per hour So what's a good number for this We don't have to be We can make stuff up Has anybody ever worked in a clothing store That would know this sort of stuff Unfortunately I did not think of this example until yesterday If I had thought of it three days ago I would have gone to a store And just watched for about 15 minutes And just counted it What do you think would come in per hour What's a good number 12 Okay so for the purposes of this simulation We're going to have Where's my cursor here Another thing we're going to need to know is How many items do people Bring in to try on And I have literally no idea Okay because I've never brought in more than two items Everybody is going to say What you only two Can somebody give me some numbers So we can get some estimates The limit is always six Okay probably because they don't want people They don't want the clothes walking away So Should we get a limit of six Evenly distributed That makes our life a lot easier Because sometimes there's going to be more people With four, five, and six items Than there are with people with one, two, and three items Okay and we could Make that into our simulation But let's have it evenly distributed Because that's just one other detail That I don't want to have to think about Now the question is How long does it take people To try on each item Plus the setup time And Making sure that everything is out of my pockets And all that kind of garbage And the You're ready to Those are separate things But how long does it take each person To try on an item Again I have literally no idea So anybody can just give me some estimates From their own experience Three minutes per item Okay So we have about Between one to three minutes Okay and that's going to be Randomly distributed In intervals of let's say One half minute That sounded about right Pardon Oh that means Instead of just having one minute Or two minutes or three minutes They can take one, one and a half Two, two and a half and three Okay so we can A complete minute they can take a half minute Somebody can try on Per item is going to be One and a half minutes Okay And then we also need to know Is the average setup And Teardown is not the word I want to use here Setup and So how long does it take I'm going to say let's say one minute To set up As that's the From the moment you get in there Until you're ready to start trying on the first item And one minute to Get ready to leave the room That's not about right And we'll just make it one minute For everybody Rather than making it some random number Okay I think Is there anything else I have forgotten here In terms of what we need to do We want to Notice that by the way I'm just planning before I even start writing A single line of code I do not want to write the whole program And then make these decisions afterwards That's just totally backwards Yeah I have to figure out What is the scenario I am trying to simulate And then I can start writing it So now the question is What objects will I need Yeah Well I'll definitely need a customer Right And I'll need A queue of customers Because the customers are standing in line The fitting rooms are not standing in line anywhere They're just there Then I'm going to need a fitting room Class And I'm going to need To have a certain number of them And now do I need Are they going to be just a plain old Array list A stack or Another queue Again this is a design decision Array list Fitting room is number 123456 Because we're computer scientists Fitting room is number 035 Fitting room And we're going to need Array list This is the not exciting part Of writing a program But we really need to make All these decisions first Now what does a customer need to have Do we need to know their name And their age Who cares What we need to know is What's the most important thing We need to know about the customers Exactly So the number of items Which is an integer I'm doing a sort of a UML diagram Here on the fly But that's okay I hate autocomplete There we are And what else do we need to know Pardon How long it takes them to Try on each item Okay yeah I guess that would be Belong to the customer Sure that would be okay Time per item Which is also going to be an integer No no no Is it going to be an integer or a float So what we could do Is just multiply it by four To get our or to multiply By two to get our half minutes Okay so let's make an integer Measured in Half minutes Okay great Now what do we need to know We also need to know is Definitely the timestamp Because again one of the things we want to Oh that's what we forgot to design Here by the way What are we measuring anyway That would be nice to know wouldn't it Because that's going to affect All of our other choices Well one thing we definitely want To measure is the average Time spent in the queue Yeah Do we want to figure out The average amount of time That each fitting room is in use Or not I don't think there's anything else We need to know If so you can think of something else So let me know We'll work on that Now the question is What does a fitting room have to have Well it has to have a customer In it doesn't it Okay we have a customer That is in a fitting room And if it's null if empty I don't like using null as a flag We could have a boolean saying Is empty Do we want a boolean flag Just check if it's empty Or look for the fact that there's A customer object in there How would you like to do that I like the boolean more here So in fact let's call it Let's call it client We have a customer type We'll have a available It's spelled out right yes Which is a boolean And what else do we need to be able to We're going to need methods On this as well Okay who is responsible Who owns the zebra Who is responsible for doing that Saying whether there's time left We're going to need a start time And then we're also going to need An end time Yes Now one of the methods that we're Going to have to do here When we have an end time And a start time We also need to be able to look At the current time So we're going to have These are going to be in seconds Not in minutes Because why I could make them in half minutes So it matches our Our timing here I just want to do it in seconds This just seems to be A better idea All of these are design decisions That I've made Now some of them may turn out to be Really good design decisions Some of them may be really crappy ones I have not written this before I'm writing this right now on the fly To be quiet I'll tell you right now So I have no idea how this is Going to work out in the long run But at least I have a plan Okay Why don't we start off With our customer class So let's open up our template file And this is going to be Okay So here's our class customer And we're going to have I guess we can And then we're going to need a Constructor for it And we're going to have here I don't believe we need any more methods On this one We do need one actually You know what, this would be really nice For the Republic So we have a customer With percent sign D items Percent sign Dot one F Minutes per item Entered At Ten percent D And I've got to divide by 2.0 Because otherwise I'd have integer division Which is not what I want Because these are half minutes So that would give me the actual minutes And then I have this dot time stamp But I don't want to do system.out.printf I want to return string.format Okay, because I'm returning a string Which one, what line number Let's just compile that Okay, that's great Now Okay, the way I did this by the way In the The way that they do it in the Printing Is they do something They create a Fitting simulation object And then call methods on that Let's just test Let's put something in here Just to test things out, okay Customer C is new customer Let's say I have 5 items The time per item is going to be 3.5 minutes And the time stamp is going to be 0 Okay, that looks good Now what I have is a It can't be public And once I have this class available I'm going to wait for my main method I haven't figured it out quite yet I noticed I didn't design on the main method So I may have to come back to my design document And do that In the meantime, what I can do Is I can at least Grab this here I'll pop it back in here So let's see, we have Private customer client Private Boolean available Private integer Start to time And private end time And then we're going to need a Constructor Yes So we're going to need Public Hitting room Which is going to have a If we do it I think I'm going to use one for an empty room And I'm also going to need one for One that has data in it So for an empty room We have The client is null Available is true And start time is 0 Now this is going to be interesting When I have a client come in They already have the number of items And we also have the time stamp So I know the start time I don't have to provide a time stamp, do I? I don't have to provide a start time Because the Yeah, the client tells me when they entered the queue Oh no, no, no, I do need to know that Okay Very important point here Very important point here I'm going to write this as a note to myself There are two different slimes Going on here One is the client's time stamp Namely when they entered the queue Versus the fitting room start time Which is when the Client got into the room in the first place Those are really different And I almost put them together as the same object That would definitely not work Yeah The difference is Let's say that we have Let's say we have Joe Nancy and Fred Are in here I'm going to need to go to a separate page here to make this work So let's say Fred Entered at 10 o'clock And Nancy At 10.05 And Joe is at 10.06 Okay So let's go to their time stamps Right Now let's say we have a fitting room here And there's in our first fitting room in the room A Is occupied Let's just have two fitting rooms for right now so that I can make this hit And And let's say they're both occupied by somebody Okay So now when Fred started at 10 o'clock But notice it's past 10.06 isn't it Because Joe is here So when Fred goes into dressing room A Let's say there's this So A and B are both occupied It's here I've been pasted Now Fred is going to be in here In dressing room A Because it became available But notice that even though he came in It is now 10.09 Okay Because this is when he entered the queue He came into the store at 10 o'clock To wait for a dressing room But he wasn't able to get one until 10.09 That means he's been waiting for nine minutes And that's his start time in the dressing room This is And then we might have At 10.13 Is When Fred will be Done trying on his items So this time stamp here is definitely not the same As the time that they entered the dressing room Now this may seem silly to you That I'm having to go through and talk Say all this stuff So somebody said, well, yeah, of course No, this is not of course And I am not trying to convince you folks That this is correct I am trying to convince myself That this is the right approach Because I have to have this straight in my mind If I'm going to be programming it So thank you for asking that question Because that cleared it up for me Now I know exactly why these two things are different I had to talk it through And sometimes you just have to talk it through with And it doesn't have to be somebody who knows the assignment By the way You just find some relative or friend And just if you're stuck on something You explain it to them what you're trying to do And as you're explaining it It will all come into place for you It's amazing how that works So those are two very different times Yes So we need to know In our fitting room We need to know the client And we're also going to need their start time And so this is going to be Well definitely we're going to say This dot available Is false Stop Why do I want to create a new fitting room? I don't want to create a fitting room With a client in it That doesn't make any sense At all Okay What I need to do is I need to put someone in the fitting room And I want them to get out of the fitting room Yes Okay so This is part of the design process You look and say Wait a minute Why am I creating a brand new fitting room That doesn't make any sense at all So we've got to go back here In a design document We need to say Enter and give it a customer And exit To get rid of a customer There we go Okay Now this makes more sense That's the way fitting rooms actually work When we get a new customer We don't build a new fitting room That's just weird We should say hey Go into room number five So we're going to have a public void enter Customer enter And then we're going to have This dot client becomes our customer Now the room is no longer available And we're also going to have to customer Client And we're also going to have to have an integer Entry time The fitting room is no longer available And this dot start time Becomes our entry time Now what's our end time Okay Well we know that it's going to be Two minutes Time has two minutes Start up Finish Plus Random number from one to three Times the number of items Okay I guess that means I'm going to need to have Import java.util.arraylist I'm going to need that at some point And java.util.random Okay Do I want to put the random number generator here As part of the fitting room Or create a new one on the fly I guess a minor point I'll just create one on the fall fly What the hell And then what we're going to do is This dot end time Becomes Entry time Plus Two Plus Okay We have a random number It's one, two, or three But we have to multiply by two So it's from one to six Yes So that means we're at random five Plus But we're measuring everything in seconds, aren't we And we're going to have to multiply that by 60 To get number of seconds For the start time and the end time And then we're going to divide it by two Why are we dividing by two Because we have the half minutes And that allows us to figure out If a customer has entered or left Yes Okay, a customer has entered That's what we have to do when a customer comes in Thank you That would be good idea And then public void exit And that's just a variation We just need to set this as available To be true Yeah, there's going to be all that other information Left around, but the next time We have another customer enter It's going to overwrite all that other stuff And let's compile this just to see that it compiles Okay, well, that's exciting Yeah, try client You cannot assign a class to a variable There we go Okay, let's stop here for a moment Let's take a ten minute break Okay There's a lot of stuff going on here Yeah, you're seeing me working without a net here, by the way I'm just writing this on the fly Okay So all these little errors All these little things that I come up with And say, oh, I forgot about this I go back, write down my decisions And then I come back and implement them So I don't know if you all go through this process Yourself while you're writing it Writing your assignments But that's the way it works Normally in a corporation, by the way You have a much better design document than this Okay, we have all the specifics All of that would have already been planned out So Welcome to improv day And I still haven't done this tick business here, have I? Well, we'll worry about that later Okay So ten minute break Well, I think about Is this really what I need? I think after the break I'm going to do a little bit more design And I might I don't think I'm going to be able to write this all during the lab So after the break I'm going to be doing more Design work and figure out what the The main method is just baffling me right now I've got this half formed idea in my head Of what it needs to look like And by the way, what I'm doing here might not look Anything like what the book did with the printing simulation Okay, I'm going to take that right now Their design and my design are two totally different things The idea is the same, but I'm just approaching it maybe in a Totally weird manner Meanwhile, let me pause the recording Okay, I'm going to do another ten minutes of this design stuff here And then a little bit of the code So We were talking during the break about, okay We need to figure out how long a fitting room has been in use So that means each fitting room is going to need a total time So that means here we're going to have to have a Total time Which is an integer And we also We have the start time and the end time But we want to know what the current time is Yeah, so that's independent of the start time That way we will have the start time and the end time Well, we want to preserve them It's just a good idea to do that Couldn't you make that static? There was only one part Could I make that static? I might be able to, but I want to make an instance variable The question was could I make it because it's being recorded Could I make this a static variable? Because all fitting rooms have the same current time I'm not sure But it's relative to start time Okay, so this is actually So it's relative to start time But it can change Every time the clock ticks Okay, that's why it doesn't feel right to be static Static is highly overrated Okay All right, so that means we're going to have to do some stuff here in our code We have our total time So we can check it against the end time to figure out whether we're kicking the customer out or not And then we're going to have a private total time Total time the fitting room is in use So when we create a new fitting fitting room Then definitely the end The total time is going to be zero And we may as well set the current time to zero also Can't hurt so now when somebody enters That's also the current time we're going to set the current time to our entry time Now since we know what the end time is we could do the total time right here Total time plus and becomes this dot end time minus this dot start time Because we know that's how long that's going to be before they Finish up doing their thing now we need the tick method And what that's going to do is it's going to say this dot current time plus plus And and then if how about spelling it correctly if The current time is Equal to the end time Then we call exit We kick the customer out of the fitting room when their time is expired when they because where they're they're through doing their their stuff Do I want a Two string Yeah, you better believe I want a two string I might need to do a lot of debugging here So we have public String two string And we're going to say return string dot format Okay, let's see what are the things that we need to know. We don't really need to know That's going to be a true or false value Let me check to make sure that's correct. I think that's how you do it So I need to go into JShell. This is one of the again This is what I'm going to be doing when I'm doing ordinary programming I'm doing this actually as though I were writing the program for the first time which I am Let's have a Boolean variable called Yes, no, and let's set to true And then let's do Boolean dot two string of yes, no Yes Okay, I knew that My intuition was correct. I would have looked it up also. I could have looked it up But this is easy to try it out and see what happens So I'm going to This dot string Like this This dot starts the time This dot end time and this dot current time Let's compile. Let's make sure it's okay. Good. No, and now what we're going to need to do here Is figure out what our main method is going to do So the main method is going to call the simulate Method Which takes these parameters First parameter is going to be the number of fitting rooms we want And this could be by the way a plain old array. It doesn't really need to be an array list because we know the number in advance So whatever I put down here for an array list Did I say it was going to be an array list? No, I didn't. Okay I did say This is the kind of thing that I do when I'm taking my notes. The number of fitting rooms we want And we want the number of seconds to run the simulation And then we want the number of customers per hour So here I'm going to have a voice simulate And it's going to be in rooms I just wrote it down. I forgot it. Okay Typical of me. Number of seconds And that way we can run simulations with different numbers without having to I'm compartmentalizing it So now what we're going to do is we're going to have An array of fitting rooms And it's going to be New fitting room And rooms And then we're going to have Int The current second is zero We can run it as a for loop. It'll be easier as a for loop. Now the question is when we're going to have our arrival time Remember the arrival time is going to be the number of Seconds in an hour divided by so that means integer Has a magic arrival number Is going to be 3,600 divided by the customers per hour And we're also going to do a random number to tell us whether we were randomly generating So random Generator is new random Tell you what let's just do it right now just for debugging purposes Oh, we need a name for this array. Don't we I was wondering why that looked wrong. Okay I plus plus Let's do system dot print line Room Plus I plus colon Plus So now to do this what we're going to need to do here. I guess I don't need my in I'll keep the scanner here It couldn't hurt So we're going to do here is we're going to say Fitting simulation the simulation is going to be a new fitting So I'm going to make an instance of this application And then I'm going to say the simulation that simulate and we're going to have how many rooms do we have six rooms How many how many fitting rooms do we want to have in this simulation Let's have four four rooms and We're going to go for two hours, which is going to be 7200 seconds And the customers per hour we said we're going to have 12 Well, this is this is exciting. Okay, that's because these guys here Need to be in our main or don't they what happened to my main I must have Oh great There it is Okay, we still have this problem here That's fitting room This is This is Customer so that's good Yeah answer it's not in any class it has to be inside a fitting simulation doesn't it amazing Notice that I want to fix my indentation here I get my indentation to get screwed up boy then everything this is going to go straight to hell in a hand basket There that's much better and now I can run it And I haven't created any oh that's that's ugly isn't it okay Why put this debug output in here. Well, that's nice to know so that means I'm going to have to say rooms so by is going to be a new fitting room Okay, lovely everything is working like a champ now. Okay I'm happy now Okay I think everybody's on information overload at this point That's going to be my timer What I'm going to do now is I'm going to say for it second is zero second less than the number of seconds second plus plus what I'm going to do is See if I need to generate a customer Okay If so Generate them and enqueue them I still haven't made my queue and queue them So that means I'm going to definitely need a queue of customer clients is going to be a new queue then what I have to do is Check all the fitting rooms to see if they are finished or not and then If a fitting room is available and anyone is in the client queue Then I have to dequeue them And put them into a fitting room. So that's what I'm good. That's what the simulation is going to do. Does that does that help Again, that's my that's my big picture here. I'm not sure quite how I'm going to implement every single bit of this but At least I've got that idea of what's going on Okay I'm going to stop the recording at this point and I guess I will pick this up on Wednesday The question is whether I should complete the program by then and then just go over it or continue developing it I'm not sure which to do what I could do is I could develop the rest of the program at home and record it Then we'd have a recording of it. I'm so indecisive. This is why it takes me so long to design these things because I'm indecisive But the rest of the time lab time if you still need to work on the stacks assignment do that Otherwise you may want to go and read the assignment for the group project on queues And that's going to be Let's go student view here a queue project And you may want to I'm going to say right now the one line for customers within checkout stations and you go to the next available station That's almost exactly what I'm doing here with this example. So this example might give you a head start on how you might want to do that So you can either do that or you can read the book now that we've looked over this stuff you can go and read it and say oh now I understand more what the book was saying Lab time do it do what you like you know where to find me