290 likes | 398 Views
Intel Ultimate. Engineering Experience. Introductions. Come on in, the code is GREAT!. Instructors. I sure do love making mobile apps!. Brad Nichols. Michael Katic. michaelkatic@gmail.com. bnichols@spsu.edu. Ryan Scott. Come try on your computer science hats!. rsscott2@asu.edu.
E N D
Intel Ultimate Engineering Experience
Come on in, the code is GREAT! Instructors I sure do love making mobile apps! Brad Nichols Michael Katic michaelkatic@gmail.com • bnichols@spsu.edu Ryan Scott Come try on your computer science hats! rsscott2@asu.edu Feel free to contact any of us for whatever reasonIf you cant figure out an error or are stuck on a design issue just shoot an email to one of our email and we’ll help out the best we can!
Facebook • Join us on Facebook • And Wikispaces!
What is Programming? • Computer Programming is the: • Designing • Writing • Testing • Debugging • and Maintaining • of source code of computer programs.
Why do I want to be a computer Programmer? • Pay • Starting Salaries in computer programming range from $59,000 to $112,000 per year • Contract jobs run as high as $100 to $400 per hour • Flexibility & Independence • Work from home as freelance contractor • Nearly always able to work from home • Bring your work anywhere • The “Do good work and we wont ask questions” policy • Demand & Job Security • As long as society relies on computing technology, there will be a demand for computer programmers. Notes from: http://www.indeed.com/ http://www.askitcareercoach.com/ http://smallbusiness.chron.com/advantages-being-computer-programmer-38637.html
Hello WoRld Time to get started
Hello World Tutorial General Structure of a C# Program Main() and Command-Line Arguments Hello, World! class Program { staticvoid Main(string[] args) { Console.WriteLine("Hello, World!"); } } TIP:Don’t forget to add Console.ReadKey(true); to stop the console window from closing.
//Commenting your code • When your programming you may want to leave behind notes. • To do this we use double backslashes at the beginning of the line we wish to put notes on. • For example: • //Print out text to the screen. • Console.WriteLine("Hello, World!"); • The line above in green will be ignored and acts as a note to whomever reads the code.
More on Types Types and Variables Declaration of a Variable intx; The line above creates a new variable named “x” of type int Initialization of a Variable x = 5; This line set our variable “x” to the value 5 Accessing a Variable intz = x; This accesses the value assigned to variable “x” and assigns it to the value of the variable “z”
More on Operators Operators We can use symbols in c# like “+, -, *, /” to perform operations. int x = 5 + 1; //This sets x to 6 int y = x + 1; //Sets y to 7 Knowing the type of the variable allows our operations to behave differently based on the type. For example observe the two different outputs below. int x = 5; int y = 6; Console.WriteLine(x + y); String x = 5; String y = 6; Console.WriteLine(x + y); 11 56
Conditional Operators • < less than • > greater than • <= less than or equal to • >= greater than or equal to • == equal to • != not equal to • && logical and • || logical or Examples
More on if else Conditional Statements (If else) bool result = true; //What happens when you change true to false. if (result) { Console.WriteLine("The variable is set to true."); } else{ Console.WriteLine("The variable is set to false."); }
More on switch If else vs. switch statements If else statement Switch Statement switch(number) { case1: // Print 1 break; case2: // Print 2 break; default: // Print number break; } if (number == 1){ // Print 1 } elseif (number == 2){ // Print 2 } else{ // Print number }
More on while loop Learning Loops int n = 1; while (n < 6) { Console.WriteLine("Current value of n is " + n); n++; } Current value of n is 1 Current value of n is 2 Current value of n is 3 Current value of n is 4 Current value of n is 5
More on Methods Declaring a Method Just like we have functions in math we have methods in C#. And just like in math our functions have some input and some output. (see example below of how to create a method) Declaration of a Method bool f(int x) { //Do some stuff in here. Dont forget to return a bool. } The lines above create a new function named “f” that takes an input “x” of type int and returns a bool value.
Method Example The method below returns true when it is given an input of “0” otherwise it returns false. boolisZero(intval) { if (val == 0) { returntrue; } else { returnfalse; } }
Calling a Method Now if I want to use my new method to check if a value is zero I can do that like this: int x = 0; int y = 5; boolxCheck; boolyCheck; xCheck = isZero(x); //xCheck is now set to true yCheck = isZero(y); //yCheck is now set to false
Classes animal.cs Main() Animal myAnimal = newAnimal(); Console.WriteLine(myAnimal.name); Console.WriteLine(myAnimal.weight + Pounds); myAnimal.Eat(); Console.WriteLine(myAnimal.weight + Pounds); Ryan 10 125 weight++; Eat() Ryan 125 Pounds 126 Pounds Note: “weight++” is equivalent to “weight = weight + 1”
INHERITANCE Dog.cs Main() Pug Dog myDog = newDog(); Console.WriteLine(myDog.breed); myDog.breed = DalmationConsole.WriteLine(myDog.breed); Console.WriteLine(myDog.age); Ryan 10 125 weight++; Eat() Pug Dalmation 10
More on Random Class More on Random.Next() Random (number Generator) Class Represents a pseudo-random number generator, a device that produces a sequence of numbers that meet certain statistical requirements for randomness. Random numGen = new Random(); randNum = numGen.Next(0, 3); //Sets randNum to either 0, 1, or 2 Inclusive Lower Bound Exclusive Upper Bound
Researching your issues • Google is your friend! • Here are some other friends you might want to become familiar with: • MSDN Learning Recources • Top C# Questions on Stack Overflow • Get More Out of Google
Getting A Jump Start on Tomorrow • Tomorrow we will be learning more about the following: • Conditionals, Loops, and Methods • Classes • Random class To get a head start you can visit the links above and play around with some of the code provided. HAPPY CODING
Intel Ultimate Engineering Experience