Skip to content

Adding Some Class


Adding Some Class


2/19/2023

I have added a class to my program after weeks of convincing myself it would just be more work. My breaking point for creating a class that contained the picture boxes in my grid was adding more advanced functions. I was thinking about how to use loops and conditionals and quickly found myself adding more and more variables. I had arrays galore and it was too much. I had an array for my picture boxes, the active square, if a square was painted, if a square was blocked. It was too much and I finally caved creating a class for each box. My class now holds the picture box, the box’s row and column, if the square is blocked and if the square is painted. Creating this class decreased the amount of variables I had and made it easier for me to keep track of them all.

Once I created a class, I took on the task of creating a while loop. This required more variables and quite a bit of thought. It was important for me to keep track of where I was in my code and to keep track of each variable. For a while loop, I need to know if we are in a loop, what the condition of the loop is and what is contained within the loop. Since I have a foreach loop that goes through the text in the text box, I had to figure out how to stop in the middle of that and repeat. In simple terms, I figure out I am in a loop by reading in the word “while”, then I go through each command in the loop storing it in an array, and finally I repeat the contents of the array until the condition is no longer true. In a similar way, I was able to create an if statement.

Right now, the only conditions I have are whether a square is blocked and whether the square is painted. It is a simple start and not too pretty but it’s working. This week, I want to focus on polishing what I have and creating more conditionals to work with my while loop and if-statement. To help me out with staying organized, I have created a document that has a list of rules for my language and what is contained in the language. This document shows what is completed, what needs to be completed and what is a work in progress.

Here is a video of the updates I have made:

Leave a Reply

Your email address will not be published. Required fields are marked *

css.php