Skip to main content

Posts

Showing posts from March, 2016

WHILE and IF statements

A while loop statement will repeatedly execute a statement as long as the given condition is true. If the while loop's condition is set to true then the program will go into the loop, and will keep looping as long as that condition remains true. For example: int score = 15; while (score  <  20)       {             Console.WriteLine("value of score: {0}"), score;              score++;        }        Console.ReadLine(); In this example the program will go into the loop for as long as the value of score is less than 20. Once it's in the loop it will increment the value of score by one, then it will check if a is still less than 20. Once the value of score reaches 20, it will no longer go into the loop as the condition will no longer be true. A IF statement on the other hand can be a bit similar to a while statement, as it will check the condition at first, and if it's true it will execute the block of code inside of it. IF the condition is

How variables and properties work/compare.

Variables are storage locations that data can be stored in. They are are a way of naming data locations that can be later on used in the program. Variables generally have four attributes: an identifier, data location, type and value.  We have used variables in most of our programs in class, for example, storing names as strings and numbers as doubles/ints. Properties on the other hand can be looked as a special type of method that exposes a variable. A property can have can have a Get procedure (read only), a Set procedure (write only), or both (read-write). Properties are effective in a way that they have access to private data inside of a class, and can manipulate the data as it enters or leaves the class. Variables and properties are both important in programming because they help store and manipulate data. Variables can be used to store and protect important user data inside of classes, and the property of those variables help manage what data is only going out into outside cl

Modular Programming

Modular programming is the practice of breaking down a program's functionality into independent interchangeable modules. Each of these modules have everything necessary to execute only that aspect of the desired functionality, in the case they are needed.  Modular programming is important because it creates a structure that keeps the code organized and easier to maintain. For example, if you had to change an object used throughout a program, with modular programming you would only have to find the module where the character was coded. Compared to not having modularization, if you wanted to accomplish this you would be required to read the code line by line having to find and edit that character everywhere it was used. Programming languages like C#, java, and C have this implemented by having different methods or identifiers. Once that is created then you are able to use those methods elsewhere in your code, which also saves time by not having to re-write the method all over ag