Saturday, June 30, 2007

Project DaysAndNameOfMonth

This project is one of many codes in the book I am currently reading, Programming in the key of C# by Charles Petzold. It is a really good book which I picked for $20 bucks on amazon. Well my objective here was to simply copy the code from the book into VS. The main reason for this is just to understand what is actuallly going on here with arrays and understanding how they work. I think i have a real good understanding now but I will find out Monday when I have to ask 3 questions regarding this code. Well here now I will post my 3 questions and maybe I will get my answers before then.

1) Why was this done without defining how long the arrays would be?
Ex: string[] astrMonthName, but instead string[12] astrMonthName

I was supposed to have 3 questions but I could only come up with one.

Here is the code:

namespace DaysAndNameOfMonth
{
class DayAndNameOfMonth
{
static void Main(string[] args)
{
string[] astrMonthName = { "January", "February", "March", "April", "May",
"June", "July", "August", "September", "October",
"November", "December" };
int[] aiDaysInMonth = { 31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31 };
Console.Write("Enter the month (1 for January... 12 for December): ");
int iMonth = Int32.Parse(Console.ReadLine());
Console.WriteLine("{0} has {1} days.", astrMonthName[iMonth - 1],
aiDaysInMonth[iMonth - 1]);
}
}
}

Friday, June 29, 2007

Frustration

Wow I reallly want to learn C# and eventually other languages. I wont attempt another language until I am happy with my knowledge of C#. Baby steps, I have to remember it is all about baby steps. I know I will eventually get there. I want to have a full knowledge of C# by years end. Then next year I can move on to other languages. I just have to keep my head and keep trying. I wont quit. I will make this happen.

Thursday, June 28, 2007

Project NumberLoop

Real Funny.....................My teacher has discovered that i am overengineering my progress. It seems that I have been making things seem more complicated than they are. To solve this problem I have been assigned smaller projects so I can better understand how everything works. I will then start to combine what I have learned into bigger projects. For this project I am keeping it real simple. I am just using a for loop to print out the #'s 1 - 10. I am using a for loop because I know exactly what values I want returned. Here is the simple code:


namespace NumberLoop
{
class NumberLoop
{
static void Main(string[] args)
{
int n = 11;
int i = 0;
for (i = 1; i < n; i++)
Console.WriteLine("The Numbers in the Loop are: " + i);
}
}
}

Tuesday, June 26, 2007

R.I.P. Chris Benoit

Rest in Peace Benoit family

Friday, June 22, 2007

Project FlipFlop

Today I completed the FlipFlop program. Similiar to the previous passcode program I ask for user input to perform an action. This time the action is to flip the two present numbers. The tries allowed are unlimited. One major difference between this program and the previous was the fact that project passcode used strictly strings and project flipflop uses strings and integers. Below is the code.


namespace FlipFlop
{
class FlipFlop
{
static string strSwap = "swap";
public static void Main(string[] args)
{
string strInput;
int iInput1 = 5;
int iInput2 = 10;
int tempInput = iInput1;
do
{
Console.WriteLine("The first number is: " + iInput1);
Console.WriteLine("The second number is: " + iInput2);
Console.Write("Type swap to swap the numbers: ");
strInput = Console.ReadLine();
if (strInput == strSwap)
{
iInput1 = iInput2;
iInput2 = tempInput;
Console.WriteLine("The first number is: " + iInput1);
Console.WriteLine("The second number is: " + iInput2);
Console.WriteLine("Swap Done");
}
else
{
Console.WriteLine("No Swap");
}
}
while (strInput != strSwap);
Console.WriteLine("You are the SwapMaster");
Console.ReadLine();
}
}
}

Project Passcode

Earlier this week i created a program that ask for a passcode in the form of user input. The idea was that you have a certain amount of tries to enter the passcode before the system locks you out. This was my first time using loops. Below is the code that i used.


namespace Passcode
{
class Passcode
{
static string strPasscode = "pinkmonkeybutt";
public static void Main(string[] args)
{
string strInput;
//counting variable//
int i = 0;
do
{
Console.Write("What is the passcode: ");
strInput = Console.ReadLine();
if (strInput == strPasscode)
{
Console.WriteLine("You have gained access");
}
else
{
Console.WriteLine("Access Denied");
}
i++;
Console.WriteLine("try #:"+i);
}
while ((strInput != strPasscode) &&amp;amp;amp; i < 3);
if (i == 3 && (strInput != strPasscode))
{
Console.WriteLine("You have been locked out bitches!");
}
else
{
Console.WriteLine("Welcome to the system.");
}
Console.ReadLine();
}
}
}

The Beginning

This is my first post of what I hope to be many. I am currently learning to program in C# and will show my progress. I hope to become a programmer specifically in game development. I have a very knowledgable friend who also is my teacher. With his help I hope to finally find my career track.

//The Beginning of my programming career//