![]() The goal of this problem is to transfer all of the cubes from the leftmost stack to the rightmost stack in such a way that no larger cube can sit on top of a smaller cube. For example, we might start moving the smallest cube on top and moving it over one stack. ![]() Made one step in the Tower of Hanoi problem and we've gotten maybe slightly close to removing this entire stack from the source here to the destination. Next thing we might want to do is to go ahead and take this purple cube and move it all the way to a destination. The idea here being that we can't put it on top of this yellow cube because that would put a larger cube on top of a smaller cube. Something that's against the rules of this game. After removing the purple cube, then we have only two options now. We can't move the orange cube on top of anything because the orange cube is too large. Instead, our options are really to move the yellow cube on top of the purple cube or the yellow cube on top of the orange cube. Here, I went ahead and move the yellow cube on top of the purple cube, which leaves a space to move the orange cube down on top of the empty stack. We can continue this process of juggling these cubes all around with the goal being that we want to slowly move the largest cubes to the right. Notice that here I've stacked up all three of the cubes except for the largest cube in the middle, and now I can go ahead and move the largest cube from where it began to where we eventually want to indent. This process continues, but we want to talk about how we can represent this problem programmatically with code. So, what I see here is I see three distinct classes or three distinct things that we want to represent. The first thing I see is we have these cubes. So, we already have a class to represent our cubes. ![]() So, we're going to use our UIUC cube class to represent a cube. But I see these cubes don't just have a length, they also have a color. So, I'm gonna go ahead and use a color to represent the cube in addition to its length. So, we want to modify the cube class, and we'll do that in just a minute. The second thing I see, as I see three individual stacks. I see this as this maybe stack at index zero, a stack at index one and a stack at index two. So, what we have is we have a series of individual stacks. All three of these stacks are part of something even larger because we need some container to store the stacks. Here, the entire container might just be called the game. So, inside the game, we have stacks and in each stack we have cubes. That's the relationship we have between the game, the stacks, and the cubes. Let's go ahead and build a program that creates a number of different classes to represent all of these entities. So, in last week's assignment, you built the UIUC HSLAPixel. You already know how to represent a color. Let's go ahead and see this cube come together. Here, I've modified the cube constructor to have a length and a color, and because we've modified the cubes construction of a color, we're going to store that color in a new private member variable. Pay online, by phone or stop in and let our friendly managers help you.So, a cube is different than before in the sense that we now have a cube that has both a length and a color. We offer a variety of payment options to make paying your rent easy. You only pay for the time you need, whether it's one month or ten years. Our tenants love our month to month lease agreements with no long term contracts. Regardless of your storage needs, our well trained and knowledgeable staff that will be glad to help you find the space that will work for you! Homeowners love our well lit property and fully fenced property with electronic gate access and businesses and those with busy schedules love our extended gate hours. Our facility offers vehicle storage, drive-up access, as well as non-climate and climate-controlled storage units. Move It Self Storage - North 10th St is located in the Northern sector of the Business district of McAllen. We pride ourselves on maintaining a safe and clean storage facility with customer service that goes above and beyond. About Move It Self Storage McAllen, TX - North 10th Street South
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |