C# Basics These slides are designed for Game Design Class

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Air Force Institute of Technology Electrical and Computer Engineering
Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
Slide 1 Summary Two basic concepts: variables and assignments Some C++ practical issues: division rule, operator precedence  Sequential structure of a.
CS 117 Spring 2002 Review for Exam 2 March 6, 2002 open book, 1 page of notes.
CONTROL STATEMENTS Lakhbir Singh(Lect.IT) S.R.S.G.P.C.G. Ludhiana.
 Decision making statements Decision making statements if statement if...else statement Nested if...else statement (if...elseif....else Statement) 
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
Today’s Lecture  Boolean Expressions  Building, Evaluating & Precedence Rules  Branching Mechanisms  if-else  switch  Nesting if-else  Loops  While,
Fundamentals of C and C++ Programming Control Structures and Functions.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
More on Input Output Input Stream : A sequence of characters from an input device (like the keyboard) to the computer (the program running). Output Stream.
C Program Control Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010 Fall.
CSE1222: Lecture 6The Ohio State University1. Common Mistakes with Conditions (1)  Consider the following code: int age(26); if (age = 18) { cout
© 2000 Scott S Albert Selection Structures Structured Programming 256 Chapter 4.
Chapter 3. Outline Relational Operators Loops Decisions Logical Operators Precedence Summary.
Review the following: if-else One branch if Conditional operators Logical operators Switch statement Conditional expression operator Nested ifs if –else.
Conditional Structures UNIVERSITY OF THE PUNJAB (GUJRANWALA CAMPUS) ADNAN BABAR MT14028 CR
Lecture 2 Control Structure. Relational Operators -- From the previous lecture Relational Operator Meaning == is equal to < is less than > is greater.
4.1 Object Operations operators Dot (. ) and new operate on objects The assignment operator ( = ) Arithmetic operators + - * / % Unary operators.
Lecture 4: C/C++ Control Structures Computer Programming Control Structures Lecture No. 4.
1 Chapter 4: Basic Control Flow ► Chapter Goals  To be able to implement decisions using if statements  To understand statement blocks  To learn how.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Quiz 3 is due Friday September 18 th Lab 6 is going to be lab practical hursSept_10/exampleLabFinal/
© M. Gross, ETH Zürich, 2014 Informatik I für D-MAVT (FS 2014) Exercise 4 – Logical Operators & Branching.
Control statements Mostafa Abdallah
Lecture 01b: C++ review Topics: if's and switch's while and for loops.
BOOLEAN OPERATIONS AND CONDITIONALS CHAPTER 20 1.
STRUCTURED PROGRAMMING Selection Statements. Content 2  Control structures  Types of selection statements  if single-selection statement  if..else.
Control structures in C by Dr P.Padmanabham Professor (CSE)&Director Bharat Institute of Engineering &Technology Hyderabad Mobile
C Language 1 Program Looping. C Language2 Topics Program looping Program looping Relational operators / expressions Relational operators / expressions.
 2003 Prentice Hall, Inc. All rights reserved. 1 Basic C++ Programming.
Session 2 Operators, Decisions and Loops. Objectives Operators Casting data Decision marking structures Loops break, continue, return.
Control Statements: Part1  if, if…else, switch 1.
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
CSE202: Lecture 5The Ohio State University1 Selection Structures.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 2: Control Structures (Selection & Repetition)
C syntax (simplified) BNF. Program ::= [ ] Directives ::= [ ] ::= | |… ::=#include > ::=#define.
 By the end of this section you should be able to: ◦ Differentiate between sequence, selection, and repetition structure. ◦ Differentiae between single,
IST 210: PHP Logic IST 210: Organization of Data IST2101.
Python Basics.
The Ohio State University
Chapter 3 Selection Statements
CHAPTER 4 DECISIONS & LOOPS
The if…else Selection Statement
UMBC CMSC 104 – Section 01, Fall 2016
EGR 2261 Unit 4 Control Structures I: Selection
CSC113: Computer Programming (Theory = 03, Lab = 01)
User input We’ve seen how to use the standard output buffer
Expressions and Control Flow in JavaScript
Control Structures – Selection
.Net Programming with C#
We’re moving on to more recap from other programming languages
3 Control Statements:.
Flow Control Statements
Logical Operations In Matlab.
Introduction to Programming Using Python PART 2
Summary Two basic concepts: variables and assignments Basic types:
Computer Science Core Concepts
Chapter 4: Control Structures I (Selection)
Control Structure Chapter 3.
Welcome back to Software Development!
Relational Operators.
Fundamental Programming
Decisions, decisions, decisions
Repetition Statements (Loops) - 2
Control Structure.
Problem 1 Given n, calculate 2n
Lesson 3. Controlling program flow. Loops. Methods. Arrays.
Presentation transcript:

C# Basics These slides are designed for Game Design Class Science and Culture University By Alireza Seddighi. Email: alirezaseddighi@live.com

variables Type Name = value; Float speed = 5.2f; Double power = 4.1; Int points = 0; Bool isTrueOrFalse = true;

Comments 2 Types of comments: One line comment Start with “ // “ and then the comment Multiple Lines Comment Start with “/* “ Enter the comment in multiple lines And End with “ */ “

Print in Console 1. using print function 2. using debug.log Print(“the things you want to print in console”); 2. using debug.log Debug.log(‘the things you want to print in console”):

Assignment and Arithmetic Operators Assignment Operators = += -= *= /= %= Arithmetic Operators + - / * %

Comparison and Logical Operators Comparison Operators == Equal to != Not Equal to > Greater than < Less than >= <= Logical Operators && And || or ! Not

Function Create the function : Calling the Function: Note: Accessors Type name () { The Functionalities } Calling the Function: FunctionName(); For example in Start function() or in Update Function() Note: there is other prebuild Functions void Awake (){}. What’s the use of this Function?

4 type of functions Type 1: Type 2: Type 3: Type 4: Takes no argument and does not return any values Type 2: Takes arguments and does not return any values Type 3: Takes no argument and returns values Type 4: Takes arguments and returns values

4 type of functions Type 1: Takes no argument and does not return any values Void print(){ Debug.log(“print”); }

4 type of functions Type 2: How to call: Takes arguments and does not return any values Void printArgument(string message){ Debug.log(message); } How to call: printArgument(“String”) ;

4 type of functions Type 3: Takes no argument and returns values Int returnTheValue(){ Retun 2; }

4 type of functions Type 4: How to call: Takes arguments and returns values Int returnTheSum(int a, int b){ Int c = a + b; Retun c; } How to call: returnTheSum(number 1 , number 2);

Code Flow Controlling Code Flow

Code Flow First rule Start from Top to bottom And it goas Left to right

If Statements Statements that run code based on a scenario being true or false, generally written if x then y, else z else if Else If (this condition x is met){ do this }else if (this condition y is met){ }else { Neither of the conditions are met then do this } Note: it is a good practice to use if and else if statement only if you have less than 5 conditions What’s the alternative then ?

If, else if, else

Switch/case Statements Usually used when to much condition must be checked. Switch /Case Switch (Some variable like Weapon) { Case 1: Debug.log(“knife”); Break; Case 2: Debug.log(“axe”); Case 3: Debug.log(“dagger”); Case 4: Debug.log(“bow”); Default: }

Write a code with if/else and switch/case Randomly generate a number between 1 t0 5 Assign each number between 1 to 5 to a weapon Check the weapons with if/else if /else and switch/case

Switch Statement

Loops Multiple repetitions of the same task Type of loops For While Do while Foe each

For loop If(lower bound ; upper bound ; number of hops for increase of decrease) { Debug.log(“something”); } If (i=0; i< 10 ; i++){ print(i);

For loop

While loop While (the condition is true ){ Print (“”); } int a = 0 While (a < 10){ Print (a); a++; Note: infinite loop problem

While loop

Do while loop

For each loop

arrays Create multiple variables of the same type Is a fix sized data structure Type[] name = new type [size]; Note:index out of Bound