2. Operators
Operators in C # are special symbols that specify what operations to perform on
operands.
C # has different operators that have different meanings depending on the data of
the types of operands.
C # operators usually have one or two operands. Operators that have an operand
are called unit operators.
5. What is IF Logic?
An if statement is a programming conditional statement that, if
proved true, performs a function or displays information
They work with variables
They can only be inside methods
Can’t declare outside of the methods inside the class
a general example of an if statement, not specific to any
particular programming language.
7. Problem
In the state of Herat where we live, The driving age is 7
Make a program to check if you are eligible to drive!
And if you were eligible print out “Hey You Are Eligible”
10. Else statement
If condition returns true then the statements inside the body of “if” are executed
and the statements inside body of “else” are skipped.
If condition returns false then the statements inside the body of “if” are skipped
and the statements in “else” are executed.
11. Problem
In the state of Herat where we live, The driving age is 7
Make a program to check if you are eligible to drive!
And if you were eligible print out “Hey You Are Eligible”
And If you were not eligible print out “You can’t drive”
13. Input Manager
The Input Manager window allows you to define input axes and their associated
actions for your Project. To access it, from Unity’s main menu, go to Edit >
Project Settings, then select the Input category.
18. KeyCode
Key codes returned by Event.keyCode. These map directly to a physical key on
the keyboard.
KeyCode.Space
KeyCode.A
KeyCode.Enter
Keycode.P
19. SerializeField
When you want a private member to be visible in inspector we use SerializeField
//because it has the SerializeField attribute applied.
[SerializeField]
private bool hasHealthPotion = true;
20. Challenge!
Make a program to collect points every time the user presses space key.
Points should be visible only to player and also in the inspector
21. Challenge!
Make a program to collect points every time the user presses space key.
Points should be visible only to player and also in the inspector
If points are greater than or equal to 50 then print “You are awesome”
22. Challenge!
Make a program to collect points every time the user presses space key.
Points should be visible only to player and also in the inspector
If points are greater than or equal to 50 then print “You are awesome”
Make a condition to print “You are awesome” only once
Check if we have printed the text don’t do it again
23. Homework!
1. Write a C# Sharp program to read the age of a candidate and determine whether
it is eligible for casting his/her own vote.
1. Test Data : 21
Expected Output:
Congratulation! You are eligible for casting your vote.
2. Write a C# Sharp program to check whether a given number is positive or
negative.
1. Test Data : 14
Expected Output :
14 is a positive number