 Okay, I guess we should pick up where we left off. Which means I better open the file here. I guess that would be that would be helpful indeed. And this is where we were and I looked at the code once I got home on Monday. And one of the things I wanted to make some changes to the code. This is what happens. Sometimes you'll be in the middle of a project to say, okay, some of this is not good. For example, we have some bad variables like timestamp. Well, what's what time is it? You know, what does that really mean? And that's the one that's here inside of customer. And really, it would be better if we said. Q entry time. Now we know what it stands for. So that's a much better name for it. Unfortunately, that means we have to change all the occurrences, but luckily, we can do a replace all. So I can replace timestamp with Q entry time. And that gets all those fixed. Now here I had the start time and end time. Yeah, well start of what end of what I think this would be better as the room entry time. So in fact, why don't I do this? Let's change start time to room entry time. And then the end time. Let's change end time to room exit time. And current time is fine. We can keep that exactly as it is. So now we have some better names. And you'll notice by the way I've been using almost all your editors will have a global search and replace. I don't know if you've used those before we can replace all the occurrences. It's very handy to be able to do that. So that takes care of this. What should be exposed via the centers and getters. Now, if we were doing this, if I had a lot of time, I would go through and do an analysis of each of the properties of the field of the classes and say, okay, which things do I really need other people to be able to set. And which do I need to be able to retrieve. And frankly, I, that's a lot of work. And I don't want to take the time to do that. So I'm going to do something sneaky. Instead of having everything being private. What I'm going to do is I'm going to change it to protected. What protected is, is it's one level more secure than public public is anybody can use it anywhere. If I make it protected, then it's not available to just everybody in the universe. But all of these properties will be available to all of the classes that are in this package of classes. And that's what I like. So I don't have to write getters and centers. So I'm sort of avoiding the problem. It's terribly unprofessional of me, but I mean, again, sometimes you have to ship the product. And that's what we're going to have to do for today. We can come back later and clean it up. See, talk about this. When you exit from the room, you should probably reset everything in the interest of cleanliness. So what I'm going to do is I'm going to grab all this code here. And let's call it a public void reset room. And then here. I can reset the room that I've created in the constructor. And when I exit, I'll do a call to reset room. And good. It still compiles. Okay. I just want to make sure of that. And that will make the room available and just make sure that all of the numbers are zero. I don't like to have numbers from the last occurrence hanging around. Other things. Who is responsible for keeping track of average waiting time? And do we want to keep track of the maximum waiting time? Yep. This is interesting. Sometimes when you have to calculate something, you have to know which class is going to do it. The customer class does not keep track of the average waiting time. Because each customer doesn't care about the average for the entire simulation. The fitting room certainly doesn't keep track of it. Because the fitting room is only keeping track of how long that person is in the room. And they don't care how long they had to wait in line before they got into the room. That leaves only one possibility. And that one possibility is the main method. The main, the simulation itself is going to have to keep track of it. Actually, I think I might have something in the chat here. Do I want to reset total time when I reset? Um, no, no, I do not. Good, good, good point. Because that's the total time that the room has been in use. And so I don't want to reset the room. So here in the constructor, I'll say. Good caps. Thank you. Yeah, that would have been really sort of bad if I hadn't, if you had not put that out yet. That brings us to the next topic here, which is bottom up versus top down design. What bottom up means is, if I could spell it would help start with the parts. And put them together into the big picture. So that's what I did. I did the customer and the fitting room. And now I need to put them together into the main method that does the simulation. So bottom down design would have started with the big picture. And built a framework sec to see that the framework worked and then add the individual parts. And why I chose bottom up design, it was not a conscious choice on my part. It just seemed at the moment that that was the best way to approach it. Some people enjoy doing top down development better. There's a difference for bottom up for some reason. I'm not sure why. But oh well. And sometimes by the way you'll have the something where you're doing bottom up and then you do top down and they meet in the middle. I've seen people actually design things that way. Okay, now we are going to go and have to put together the big picture. And his where we were we here. And usually I see if I need to generate a customer if so, I generated and queue them. Then I check all the fitting rooms to see if they're available or not. And if it's available on anyone's in the client queue then I dq and put them into the fitting room. And I actually drew a picture to see that this was what I really wanted to do. So let's say here's all the fitting rooms are filled. And we have these people in the queue. And now let me try and move this aside. So step one is to check if a customer has arrived. Put that down to the team. Yeah, let's presume that one has arrived. So let me duplicate the slide. If so, and queue them here. Copy and paste that. And let's make it great. Now the next thing I'm going to do. And by the way, normally if I were doing this, I do this with paper and pencil and actually draw a diagram. But it's just almost almost as easy to do this with one of these drawing programs. So now the next thing I have to do is go to each room. And see if it is not available. Actually, no, I don't want to see if it's available, because nobody's available right now. What I want to do is to go to each room and advance them one second. Remember that tick method that goes one second. If anyone is done, they leave the room. Yep. So that means this person's done, let's say. And so they leave. Actually, this really is. And now to be is going to be. If anyone is in the queue. Put them in the room. I'm going to do that for every room that I have. So that means that this person's going to go into there. And all of these people are going to move forward in the queue. So that's my plan. Also, what, what else has to be done with this. I have to add their waiting time. Because the total waiting time, right? Because remember, I want to get the average waiting time that they've been in the queue. And that's going to be waiting time is the current time minus the queue entry time. Do I want to check to see if the, do we want to check for the maximum wait time? Would that be interesting to know. It's not in the original specification. So let's, let's, let's skip that for now. Okay. So now I have. Oh, something happened here. This is weird. Okay. I don't know if it looked like it was bold face for some reason. Okay. Oh, by the way, I'll upload this thing here. But again, I would normally draw a picture. And you'll move things by hand and draw arrows around on it so I can see what the heck was going on. So for example, here, I'm not going to go to that. I'm not going to go to the trouble of doing the artwork. I would probably draw an arrow there. This really helps to have a picture of what's going on so you can have a mental model of it. Okay, another couple of things I want to do here is this 3,600 divided by 100 customers power. What's 3,600. So what we really would like to have here is a final int seconds per hour is 3,600. Now, it's never going to change. Although it's a constant, but it's nice to have that. Also, when I have a customer here. By the way, it should be next in six plus one because they could have six items, right? So this is going to be max items. And in here, we will have a static final integer max items. That way, if I ever need to change that, I can change it in one place. And then instead of a six, which is sort of where the hell did six come from? Okay, well, we know where six come from is now because it's the max items. It's meaningful. I also have seconds per minute. I could make this a constant for that. That's and that's sort of iffy because Sure, why not. As long as we're going to do this, we may as well. Okay, so far so good. Now what we're going to do is we're going to start putting in this stuff here. We have the fitting rooms and we've been printing them out just to see that they work for dividing line in there. By the way, let's compile this to see we don't have any errors. And let's run it. Okay, we've got four rooms perfect so far so good. Okay, see if we need to generate a customer. So what we need to do here is This is the magic arrival number. So we're going to say if generator dot next int plus one is our magic arrival number. And let's say there's again we had 12 people per hour. That's every 300 seconds correct. Yeah, so if the magic number comes out to 300 that means we have a new person coming into the queue. Otherwise, we don't. In fact, let's just do this just to, again, I like to test things out and see what happens here. Yeah, how about compiling it first. Well that's interesting. Hmm. Oh, that's because I said next int and I forgot to put the bounds on it. Magic when I do just next int that gives a number from zero to the maximum possible integer. Now I want a number between zero and magic arrival number plus minus one. When I was testing this out by the way home a couple of days ago on Monday, I'd made exactly the same mistake so that shows that I never learn. Okay, so it looks like we have customers here. So here's during the first hour. Approximately have 12345678910111213 customers okay. So that's approximately right again it's random. We might get more than 12 we might get less than 12. Okay, so I'm happy with that. So now we know that at least that part is working. And now we're going to need to do is we're going to have to generate them. So we're going to have to have a customer. Oh, this is when I need some advice. I was asking online about this. Is it okay to name a variable the same as a class. But with just the upper and lower case is different and I don't know if that's confusing or not. I'm, I'm conflicted. Does this put anybody off is this confusing to everybody if I named them the same or not. Then let's keep it that way. Okay, then we're going to have to have a new customer. And the number of items is going to be. Oh, damn. This is interesting. It looks like I'm going to have to duplicate this maximum items here, because I'm going to need it in this class also. This is ugly. Oh, wait a minute. No, haha. I just realized, since this is, this is available to me. New customer. Fitting room dot max items. That's how many and we need a random number in that range. So we're going to say generator dot next int of the number maximum items plus one. And what else do we have for a customer? When we create them the time per item. And the queue entry time. Okay. So how long is it going to take them per item. And the second that they came in, that's going to be our top of their entry time. So now this has to be a number between. I had this, I had this before. I thought I calculated this somewhere else. This is interesting. I don't think I need the time per item. Because I'm generating that a randomly in here when the customer enters the room. Correct. Then I figure out how long it's going to take them. Is everybody clear on what's happening here. Let me write this down. Okay, let me write down what the what what the problem is that I'm trying to solve. Because I'm already doing with the end of the fitting room. I'm generating the end of time. Randomly based upon the number of items. No, I still need them that these are different. Okay. I'm sorry. I'm sorry. I'm so confused here. But again, I need to know what's really going on. Different. Let's look back at this, this one here. I'm taking this. That presumes that there's one minute for each. Correct. So it takes them one. This formula is really weird, isn't it. We said it was a random number between one and three and max items is also six. That's what I'm getting going wrong. So what we really want is client dot time per item. And this time per item is going to be in seconds. No, it's measured in half minutes. Okay. So that's going to be since this is in half minutes. And then here we really do need to create a random number that tells how many half minutes there are going to be. And it's between zero and maximum half minutes. In fact, let's change this a little bit here. That way we'll be able to see what the customers got generated. Okay, this is much better. Okay. So three items one and a half minutes per item. This look right. It looks like we're getting we're getting somewhere on this. Now. Somewhere I need to do the end here. Perfect. Yeah, this is time 60 because we want to convert everything to seconds. And since these are half minutes, we're taking seconds per minute divided by two. Now I know what I'm doing. But again, sometimes I have to write this down, think it through and write it down as I think it through to convince myself. And then now that I'm sort of convinced that I got things going, I'm happy. Okay. Finally, we got our customer created. And now we have to in queue them. What's the name of our queue that we had here. So clients and queue customer. Now I need to check to see the fitting rooms to see if they are and advance them. One second. So for it is zero. I less than rooms not length. Plus, plus. I'm going to say room sub I dot sick. And that will advance them one second. And if it's exit time, then they'll exit from the room. In fact, let's put some debug output in here. Then after I've done that, I need to check to see if it's available. I think I got accidentally got rid of the brace that I had there we go. Then if client is a terrible name, let's call it the client queue. Yeah, that makes things a lot better. So if it's not empty, then that means somebody's in line, correct. And that means that we have to de queue them. So we're going to have customer. See becomes client queue. That de queue. Correct. And then what we're going to do is we're going to have to say room sub I dot enter. That customer enters that fitting room. And then we can say this is not about print line. Customer. Now, besides that, okay, let's just let's just see what happens when we do this. Okay. Well, that's interesting. It needs a customer and an integer when I enter. Oh, yes, we need their entry time. Don't we. Okay. And that's the current second. Notice, by the way, we haven't done anything with our waiting time. Okay. In fact, I don't even have it here in my simulation yet. So that means we're going to have to declare things. We're going to have to say it total time in queue. And the average time is going to be total. People de queued. Because we want the waiting time for all the people who have who have been queued. We need to do more thinking on that. Okay. Oh my goodness. Yes, that's correct. Okay. That call it total waiting time. No, total timing here. Let's call it total waiting time. No, I really do want the number of people that I've de queued. That's correct. There we go. Okay. Fine. As soon as I de queued a client. That means they're out of the queue. They're no longer waiting in the queue. Correct. They're queued. Whatever second it is now minus the time that they entered the queue and total people served are going to be there's one more person served. And then I can put them into a room. Again, I said I have to decouple the time they're in the room versus the time that they are. In the line. Those are two different things. That was what we had the question about last time. And it's still something that we have to keep in mind and think about. Okay. And let's see what happens when I do this here. Okay. So we have a generator customer entered time for this at time business. I've got to get rid of that. Where's the one that says that. That's interesting. Where is the. Oh, that's the problem. Got it. It's customer dot two string. There's a rule, by the way, there's something interesting. I'll put this in the notes. A two string. Method. Always return it. Without a new line. Let the person who receives. The string. Decide. Whether they want a new line or not. There we go. I started this at time 1493 and I'm, oh, I know why. Duh. I think I know why. You know what I'm going to worry about that later because I have the information I want. Okay. Now, once all of our seconds are done, that's the end of this loop here. Yes. By the way, for those of you who are using Jeannie. Notice that when I have the cursor in front of the opening brace, the closing braid is as highlighted in blue. So it's an easy way for you to check to see that they match up. Also, I've been keeping my indent indenting pretty much straight. So that helps. So let's do this is not a print line. Number of people still in queue. Number of people still in queue. Number of people still in queue. Number of people in queue. Is going to be. Client Q dot size. So this will tell us how many people are still in the queue. And then I'm going to say. Double average will be double. Total waiting time. Divided by total people served. Notice by the way that I'm sort of skits. Wait about whether I'm using print LN or print F. I'm not. Sometimes it's okay. What's the first thing that came into my head? Should I make them all print F to be, to be consistent? What do you think? Or should I just leave it as it is. Pardon. Yeah. It's not an efficiency thing. It's just a, yeah. How rigid and inflexible am I about rules? And I, at this point. Okay. So there's nobody in the queue when I'm done. And the average wait time was two seconds. That doesn't sound right. Yeah. This means that we're going to have to do a little bit more work to see exactly what the heck is going on. Okay. Well, it could be a lot. Let's try something. Let's go instead here. We have the simulation has four rooms. Let's say we have 40 people arriving per hour. This should be interesting. And now I have 21 people on my average wait time is a 912.9 seconds. So when we have more people, okay, there are people that are waiting. Let's say I have 20 people per hour. I should have less of a queue. Correct. And this 14.6 seconds is so that way it makes a really big difference. Apparently there's four fitting rooms looks like there's enough. What if I take instead of four fitting rooms, I have only two fitting rooms with 20 people per hour. And the average wait time balloons up. So this is now, am I sure that this, that this is working exactly the way it ought to. The answer is no, I am not. I really would need to put in more debug output on this. To make sure that things are happening at the time. I think they're supposed to happen. But I don't want to do that right now because we're running towards the end of the time. But do you see how I've been building this? Yeah. So this is definitely not a finished product. What I will try and do this afternoon and tomorrow is I will work on it and I will clean everything up. If I find any errors, I will obviously correct them. And then I will upload that. Okay. I'll upload what I have here today. And if anybody wants to take a stab at trying to fix all, trying to see what's going on and fix it, that would be terrific. I don't know if there are any questions, but there's probably, there's nothing but a gigantic question mark in front of your, in your head right now. Correct. I've done a lot of code here. My suggestion is that you definitely go through and review this code and you may want to look at the video. So you can see it happening again, step by step. But again, this is the process that I go through when I'm doing my normal programming. I do some design and then as I go along, I see, oh, this isn't going to work. And I have to rethink things or think them through more carefully. Let me just check something here real quick. Professor, do you have any comments to make? Is there anything to add? I'm not, I'm not happy with this code. It's sort of. No, I think this is great. I mean, this is a great demo of actually how software development is done in high tech companies. This is excellent. This is a short demo, but it's great. But is the code always this fragile? It's always. I've done that for many years. It is. Yeah. It's great. Excellent. Yeah, yes. The code is usually this fragile. Check the two string. I think your two string already print out at times. That's why it's double. Which two string. The customer two string already prints out at times, I think. And then I've got another at time that I'm doing here. That's. Thank you. That fixes that problem. At least I got one problem fixed before. I have to go and do a better analysis of this. Also, there is one thing that I did purposely wrong, by the way. Okay, or purposely a bad, a bad thing to do. And that's this, I noticed that nobody gasped in horror as they saw this. What's wrong. This statement works. There's nothing. In terms of doing the correct thing, it does the correct thing, but why is this bad programming style. Let's take a look at the definition of available. Does split window. Yes. This is already a Boolean, isn't it. So what value could both values should have either true or false. So do I have to compare it against true. It's either going to be true or false already. I'll have to say if the room's available. I'll have to say if, if whenever you see yourself writing to my equal equal true or equal equal false. Then that's a big red flag that says no, I don't need to do this comparison. You either have to say if rooms I dot available or not rooms I dot available. And that'll give you back a true or false value because it's a Boolean. And there's a very common error. I mean, I wouldn't take off points for that, but I would just put a comment in the situation and say, you know, you really don't need to do this comparison. And this is the kind of thing that you learn over the years as you do more and more programming. You learn that, okay, here's some things I don't need to do any. Okay, that having been done. We can now look at the assignment, which is the project and it's due on. March 8. So I'm giving you a lot of time to do it. This is a group project. And you're going to have a program called checkout dot Java that uses cues. And but before I got there's one thing I almost forgot to mention this. And that is, if you look at this code, here's this DQ here. And any queue is somewhere up here inside of the fitting room, I think. And then there's a question for my entry. Yeah, here's why I'm enqueuing a customer. And here's why I'm getting rid of. There's almost nothing to do with cues here. There's only two lines of this whole gigantic program that have to do with the queue. And this is this is normal. That's the whole reason that we have the queue. That way we don't have to worry about the extra effort of K. Well, how do we create a queue and put somebody in it. How do we take somebody out of the queue, all of this code that is inside of Q dot Java. Takes care of all that crap for us so we don't have to create an array list and push things on to it and remove from the end. That's the idea of the abstraction. We should say, okay, put this person like take this person out of the queue or put this person into the queue and all the busy work of moving an array list around is taking care of for us. Okay, so even though there's only two lines, it's also saved us a lot of intellectual overhead. We don't have to waste any neurons on. Okay, gosh, how do I represent a queue. How do I put things in how to let the queue take care of it already knows that crap. So you might have to find this on your Q project when you do this, the actual queue itself is not going to be the major part of it. The major part of it is the logic of getting everybody into the queue and out of the queue at the right time. That's where we've been spending all of our intellectual effort. When we wrote this program here. So you're going to your group is going to write something called checkout dot Java. And you're going to have three different models for self checkout stations. Scenario one, you've got one line for customers with N checkout stations. This is the way it works at the safe way where I am. And you go to the next available station. This is a lot like the fitting room, by the way, you had one queue of customers and they went to whichever fitting room was available next. Yes. So some of the code that we've developed here, you might want to look at it and oh, hey, I can use some of the ideas for that. Now, another one you have N lines for customers with one checkout station per line and you go to the line with the fewest customers in it. And I think that's the way it works at one of the smart and finals that I go to they have different different lines and each one has its own checkout station. And usually everybody goes to the one with the fewest people in it. And then the third scenario is getting in the lines for customers one checkout station per line and you randomly choose which line you go to. And we're going to run each system for two hours with the clock that takes every second. And then you're going to ask how many customers were served in total. What's the maximum queue length. And how long did they have to wait. That is the time from when they entered a queue until they were at the checkout station. And there's any other statistics that you think might be interesting. Great. Put them in. And here's your Q dot Java file. So use that. If you want to modify it, I guess you can. Don't copy and paste it into your program. Just put it in the same directory. As your program and upload everything to me and then I can so I can compile and run it. And then you'll run the program and write up a document. Well, as you can see right here. You can't just sit down at the keyboard and write the program without doing any thinking about this. Hey, can you imagine what would have happened if I hadn't done any planning at all. We'd be we'd be here in the middle of April still working on this thing. So here's some of the things that I had to consider. So you may want to think about all of those. And you'll write down all these decisions before you start programming just the way I did. You'll write down all these and some of your assumptions may turn out to be completely wrong. That's okay. None of this is engraved in stone. It's engraved in jello. And once you have your decisions, you can use them as a checklist. And have I done all the things that I plan to do. And then you're going to write a report. See if I can open that in a new tab. And so everybody's name is going to be on it. Yeah. Yeah, it's going to, for example, give it details what all the assumptions are. Yeah, it takes 20 to 40 seconds to pay it a self check out. Yeah, like that's wishful thinking. But yeah, just go with whatever you, you presume is the best estimate of these things. And then I was looking at how many customers are served, how many remained in the line, what's the maximum line length, how long they have to wait. And what was the average time that the checkout stations were in use. I never did that by the way I should have also gone back and say how long was each of the fitting rooms in use. Remember that was one of the things I wanted to do. I ran out of time on that. When I do it this afternoon when I fix it to this afternoon tomorrow, I'll fix all that stuff. I'll put it in. So you're going to have that five to six students who will be assigned to their groups by the instructor that I've already done that. If we go to student view. Okay. Under people. And you should be able to see this yourselves. I'm going to call them groups. I was going to call them group ABC and D, but that would rank them somehow. So I just picked the names of four minerals, which don't have any value judgments associated with them and they all begin with the letter C for some reason. And if you look at this, you can see who is in your group. You can also go to the people and you'll be able to communicate with them. So if you want to open up a discord for yourselves to work, that's great. If you want to just communicate by email or by zoom, I don't care how you communicate or if you want to communicate during lab. And you're physically here that works for me too. What was it keep right there. So you will decide to break into further subgroups. So you might have two people who are responsible for the one line model. Two or three people for the fewest people model and the remaining students for the random choice model. And all of these subgroups will be responsible for the overall design. So you're all going to have to work on that. So that way everything's coordinated. Yeah. Question. Okay. Program is going to be check out Java. If you do modify Q Java upload it so that I will have a copy of what you were actually working with. I'll change this. It shouldn't be last name first name. I'll have a group name. Okay. So only one person needs to submit that. And then there's a teamwork document. And the teamwork document talks about how you all work together as a team. And then the other thing that's associated with this is also a separate thing, which is the group project survey. Where you do a self evaluation and an optional evaluation of some other group member. So those are the things that we're going to have to do for the project. I have the following uploaded. I can't believe that I forgot the name of the file already. Check out Java. And what was the name of this going to be. And try and use some reasonable one that is readable by a lot of people PDF would be best. And sometimes I got some weird, you know, word processor format that's from like the 1990s and nobody can read it anymore but you have a copy of it that's not going to work very well. And then they're going to have also the teamwork document. Okay, so all of these I'm going to want only one of them, and that will be from your group. Each individual has to do the group project survey. Okay. As you can see, this is not exactly a trivial project. That's why I have giving you I'm giving you more time. And if you need more time than that, I'm going to, we'll see how things are going. Okay. But you'll definitely not want to delay starting on this. Do not wait until. As it do March 7 to start it. That would be a really, really bad idea. And other than that. Well, I ran five minutes over that's that's a new world's record for me. Break time and lab time if you still need to work on the stacks. That's fine if you want to start communicating with the people in your group. Again, you should be able to see that if you go to the people and groups, just click on a little arrow and you should be able to see that they were randomly assigned. And you see what happens here somewhere, like if I would needed to talk to Kathy Jensen, you can send a message so you can send messages to other people through canvas that way. Of course, I'm test students so I don't have the ability to do that. You folks know how to communicate electronically probably a lot better and collaborate electronically better than I do anyway. Because I'm still stuck back in email mode so I mean there's discord what else do you do you all folks use to communicate anyway when you have a group of people that you need to get together, but group meet. Okay. There's also Google groups or something isn't there. No that that would be held a setup but I'll let you figure it out. You know how to do this stuff. If you if you're at a loss for what to set up. Let's talk and let's do some research on it okay. Professor, do you have any idea as what people could use for communicating. I leave it up to them anything is fine. So when the other professor does in his class he leaves it up to everybody and whatever they do is fine. Okay, break time and lab time then. I'm going to stop the meeting at some point then I see these fun to get rid of equal equal. Okay, and let me stop the recording. Do you have any questions online phone, not not in person phone.