Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Monday, February 09, 2015

Getting back into some coding; LOOPS

Started small today to jump back into programming. I started off with some simple loops lik

(Oh also i'm going back C#)

using System

class Forever
{
        public static void Main ()
       {
             do
             Console.WriteLine ("Heya");
             while ( true );
        }
}

Is an infinite loop that will keep going while the word Heya is true. While it's continously true the loop will keep producing the line of text Heya infinitely


Then there is the while loop

using System

class While
{
              public static void Main ()
              {
                      int i;
                      i = 1;
                      while ( i < 11)
                       {
Console.WriteLine("Yo");
i = i + 1;
                       }
              }
}


In the while loop you set up the variables and give the variable or the control variable (i) a starting point. Then as the while loop progresses it adds +1 to the counter. 1 becomes 2 and increments with each passing.

This always got me though. The for loop always seemed to confuse me as it was so nested and i really couldn't make heads or tails of it but i finally got it down...

using System

class forLoop
{
public static void Main()
{
int i;
for (i = 1; i < 11; i = i +1)
{
Console.WriteLine("Sup");
}
}
}


that 3 part right there was what confused me. But it's basically the setup, when to end, how to get to the ending.


Also i really need to think of the reverse of a problem instead of gunning towards it. I have noticed a lot of my programs i did in high school involved how to NOT accept the bad values and accept the ones we want to be validated.

i won't be loading this into github as it's really not worth uploading some loops. I'll wait for a bigger program for it.

Wednesday, March 12, 2014

Oops..kinda forgot i was supposed to be practicing in java...

Wellll i kinda forgot i was going to be refining my skills and helping my friend code for a potential game he may be doing? I'm going to be freelancing it of course So at the moment this is going to be my final C# project for now. Honestly i'm glad i stopped early enough to not be in toooo deep with C#. So after this we're going back into java!!!

GlazerCalcUltra

https://github.com/s0nlxaftrsh0ck/GlazerCalcUltra

This is a heavily modified version of the original GlazerCalc in that it adds const which is a static value that is can never be changed. It's honestly a very handy tool to use for when you add final type values throughout your program. If an enemy is only 100pts and you have to code that 100pts 300 times...you don't wanna go and change 300 lines of code.

No, so all you have to do is make the const and change the const value and everything else in your coding that correlates to that const value is changed.

This also includes a do -- while loop which does an action while it is still valid. One thing i have noticed in programming is to code in reverse. It's that i have to code for what i DON'T want not what i want it to do.

So in this case instead of searching for values within my range i look for values OUTSIDE of my range which is easier to catch and a little bit neater from the looks of it. But that is something i really should take into consideration however. Sometimes you gotta see from the reverse...or make it an impenetrable fortress perhaps? But yeah. So for now...that is my last C# project.

At least with C# this taught me some fundamentals that i was a little hazy on before. Like operands and expressions, variables. And the likes. But yeah. Good times!

-Ron

Tuesday, March 11, 2014

Finally got in some coding geez...and its tuesday lol

Finally got to do some coding and reading today. Added two different programs this time

https://github.com/s0nlxaftrsh0ck/BottlePrice

basically the same as Glazing calc but calculating bottle amounts. The 99 is to offset the division so as to not give me a 0 as it divides anything less than 100 wil be 0....a bit of a better explanation...

 "If you just divide the number of tablets by 100 an integer division will give you the wrong answer (for any number of tablets less than 100 your program will tell you that 0 bottles are needed). One way to solve this is to add 99 to the number of tablets before you perform the division, forcing the number of bottles required to "round up" any number of tablets greater than 0."

and

https://github.com/s0nlxaftrsh0ck/FloatTest

This is a  program for testing out casting where you tell the program you are sure you are changing it from a larger variable to a smaller one. Something like changing an int into a float.

A float is bigger than an int. If it was int > float there wouldn't be a problem.

But since its float we need to compact it i guess you could say into the int.


Thats...what i gathered so far anyways...

Next time will be if else statements. This refresher course is pretty damned helpful and im glad im taking it back from step one to solidify my understandings of what the hell i was doing in programming. That tis be it for now

Thursday, March 06, 2014

>.>;;;

Okay  i snuck in one more shot at the github publish through bash and got it to work correctly this time!

https://github.com/s0nlxaftrsh0ck/GlazerCalc

^_^

I just had to let gitbash KNOW it's there as it's tacked as untracked. 'git add' my solution and director, do the git commit -m "add glazercalc.sln" but can't do that with the directory as it's done automatically when you push....


Add the remote origin of my git and do the git push...now why in the hell didn't the github do this...? So odd...is it only done through the bash i guess??? Hm...well these two spots helped guide me through this.

https://help.github.com/articles/create-a-repo
http://readwrite.com/2013/10/02/github-for-beginners-part-2


I hope no one will go "AUGHHH, if you're doing it why are you typing this out for?!?!?"

Honestly its kinda helping me remember. But now i have a feeling theres those who would be thinking "I wasn't thinking that!!!" And for that i apologize. You have permission to throw my cake on the ground on my birthday.

I should also just jot down notes too maybe...and also probably TAG THESE POSTS MAYBE?!?! Mrgrgr...ah well bed time for me.

-Ron

P.S. I'm not sure who else would even be reading this right now so who the hell am i even talking to?!
Finally added some coding and ran it. And it worked out. Also got it soooomewhat running up on github as well and pushed it out. Again somewhat...lol. Honestly as i was typing the code out in visual studio i kept smirking at how the autocompletes work and i missed doing this type of stuff and was pretty damned happy about it. Everytime i looked at my e-mail i had an ssh key for my GitHub and it kept reminding me of what i had to do tonight. Felt pretty good i gotta say. So yeah got a program up and pushed out a repo...somewhat. Maybe it didn't sync up correctly? I don't know...

https://github.com/s0nlxaftrsh0ck/GlazerCalc

Very odd...yeah i still need to mess around with how to push stuff out to git hub. But heres the code of the first program from the book

1    +    using System;
2    +  
3    +    class GlazerCalc
4    +    {
5    +        static void Main()
6    +        {
7    +            double width, height, woodLength, glassArea;
8    +            string widthString, heightString;
9    +  
10    +            widthString = Console.ReadLine();
11    +            width = double.Parse(widthString);
12    +  
13    +            heightString = Console.ReadLine();
14    +            height = double.Parse(heightString);
15    +  
16    +            woodLength = 2 * (width + height) * 3.25;
17    +            glassArea = 2 * (width * height);
18    +  
19    +            Console.WriteLine("The length of the wood is " +
20    +                    woodLength + " feet");
21    +            Console.WriteLine("The area of the glass is " +
22    +                    glassArea + " square metres");
23    +        }
24    +    }
25    +    

Obviously not my code or anything modded about it. Just straight from the book.


By the way there are a lot of coders around the IT Department of me. And i see them coding and i'm like...man i wish i could do that right now. Yeah the Sys Admin stuff is fun but seeing those lines of code just looking so neat and perfect and the colors. yeah...i think i'm gonna have fun honestly.

-Ron

Wednesday, March 05, 2014

Oh.

Dang...from 2005 that was my first and last blog post for almost what.........9 years? Glad they kept this going for awhile? Ahm so yeah...a loooot has happened since that last post but I'm not gonna make this a personal journal blog or anything. I'm gonna keep that jazz outta here and put it up somewhere else. Anyways. I'm making this my projects blog. At least for programming right now. Maybe music or art or something. But right now i'll be focusing on programming mostly. And im gonna focus in on C# for being able to program on the Vita and XNA i guess? But it's very close to java apparently so i can probably cross some stuff on over to android without too much of a problem...

I should probably lay out some goals of some sort as well huh?

My main focus and goal at the moment is to become a better programmer and actually know how to flesh out a program idea i have in my head, lay it out on paper, flesh out flow chart of how i want it to run and try to code it. I will probably look back at this post and say "Oh this mofuggah is so stupid and has no idea what he's getting himself into." So yes....i think im gonna start doing my reading off of this here

http://www.csharpcourse.com/ The Yellow book

And for my compliler shall be hummm...

The classic visual studio express 2013 http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-desktop

I t would be great to have these links just in case if i forget and lose them. In case of a hard drive crash. And why the hell not sign up for a github... https://github.com/s0nlxaftrsh0ck

And as i start installing all of this i might as well knock off a few pages of this book.

-Ron