variable that belongs to the class and is static to that class not to any particular method
(if you want to make it public to the application put public access identifier in front of it. )
Back
Conditional Expression
Front
-Appear inside parentheses
-expression may be simple Boolean identifier
-two operands are required when equality or relational symbols are used.
Back
local variable
Front
variable declared in a method only used within that method
Back
Two Way Selection Statement
Front
Either the true statement is executed or the false statement NOT BOTH.
if (expression)
{ statement;}
else
{ statement;}
Back
Making Decisions
Front
Central to both selection and iteration constructs. Enable deviation from sequential path in program.
Back
Matching up Else and If clauses
Front
Else goes with the closest previous IF that does not have its own ELSE
Back
SWITCH STATEMENTS EXAMPLE
Front
Switch ( weekDay)
{
case 1:WriteLine("monday");
break;
case 2:WriteLine("tuesday");
break;
default: WriteLine('not monday through friday');
break;
}
Back
Do. While statements
Front
When you want to put the condition at the end of the statement instead of the beginning
do
{ statement;
}
while (conditional expression)
Back
Equality Operators
Front
Conventional to place the variable in the first operand location; value or expression in the second location.
Back
TryParse () Method
(string someStringValue, out int result)
Front
Parse method in convert class
convert strings values sent as arguments to their equivalent numeric value.
if ( int.tryParse(in Value,out v1) == false)
WriteLine (" Did not input a valid integer-"+"0 stored in v1");
Back
Object Concept
Front
Solution is defined in terms of a collection of cooperating objects
CLASSES serve as templates from which many objects can be created
Back
Ternary Operator aka Conditional Operator
Front
General Form/
expression1 ? expression2 : expression3;
when expression1 evaluates to true, expression2 is executed
when expression1 evaluates to false, expression3 is executed.
grade = examScore >89?'a':'c';
Back
Equality, Relational, and Logical Tests
Front
> Greater than / (8 >5) / true
< Less than / ( 1 < 2) / true
>= Greater than or equal/ (100 >= 100)
<= Less than or equal/ ( 100<= 100)
Back
One- Way Selection Statements
Front
if ( expression)
{ statement};
when expression evaluates to false,statement following expression is skipped
Back
Windows MessageBox Class
Front
message box- dialog box
- invoke MessageBox.show() method
- overloaded method
1st argument - string displayed in window
2nd - caption for window title bar
3rd - type of dialog button
4th- button type
Back
Private Member Data
Front
All code you write is placed in a class
when you define a class, you declare instance variables or fields that represent state of an object
Back
One- Way If Statements
Front
if (examScore > 89)
{ grade = 'A';
WriteLine("congratulations- great job!");
}
WriteLine( " I am displayed, whether the expression " +" evaluates true or false");
Back
Nested if .. else statement
Front
bool hourlyEmployee;
double hours, bonus;
int yearsEmployed;
if ( hourlyEmployee)
if (hours > 40)
bonus = 500;
else
bonus = 100;
else
if (yearsEmployed > 10)
bonus = 300;
else bonus = 200;
Back
Constructor
Front
Special type of method used to create objects
instantiate the class
differ from other methods
do not return a value
use public access modifiers
Back
Loop
Front
Repetition or iteration structures
while
do ..while
for
for each statements
Back
Foreach statement
Front
Define a loop with a collection of data ( array)
Back
Mutators
Front
Setters
normally includes one parameter
can be overloaded
Back
Windows Application Using Loops
Front
Event driven model
designed with GUI
predefined class called message box = to show results
Back
Short Circuit Evaluation
Front
Short Circuiting logical operators
- && and ||
-OR ( ||) expressions- if the first evaluates as true ,no need to evaluate the second operand
- AND ( &&) expressions if the first false, no need to evaluate second operand
Back
State Controlled Loops
Front
Similar to sentinel-controlled loops
(flag controlled loops)
instead of using a dummy or extreme value, use flag variable.
Back
If.. Else Selection Statements
Front
Classified as one-way, two -way or nested.
Alternate paths based on result of conditional expression.
Back
Switch Selection Statements
general form:
switch (expression)- Selector
{
case value1 <-must be same type as selector: statement;
break;
default:statement;
break;
}
Front
Multiple selection structure
called a case statement
works for tests of equality only
cannot be a constant literal
can write 90 but not variable for 90
Back
Abstraction
Front
Attributes ( data)
Behaviors( processes on the data)
Back
Order of Operations
Front
Associativity :
left associative : all binary operators except assignment operators
right associative : assignment operators and the conditional operator
-order changed through use of parentheses
Back
Boolean Flags
Front
Declare boolean variable
- bool identifier
- initialize to true or false
Used as flags to signal when a condition exists or when a condition changes
Back
Accesor
Front
Getters
Returns the current value
Stander naming convention
prefix with GET
Back
For Loop
Front
Pretest form of loop
specialized form of while statement
general form:
for ( statement; conditional expression ; statement)
statement;
Back
Boolean Data Type
Front
-Bool type holds value of true or false
-when a bool variable is used in a conditional expression
Back
Method Signature
static int Add(int value 1,int value2)
Front
includes a return data type, name of the method and within the parameters any you want to pass in.
Back
NESTED LOOPS
Front
Loop can be nested inside an outer loop
-inside nested loop is totally completed before the outside loop is tested a second time.
Unicode character set used for comparing characters declared as char
- cannot compare strings using relational symbols
-string comparison == /!=
Back
Counter-Controlled Loop
-Loop control variable
Front
-variable simulating a counter
- conditional expression designed so you can exit loop after certain number of iterations
Back
Sentinel Controlled Loop
Front
Indefinite loops
often used for inputting data
tells user what value to type to end loop
Back
Method
Front
Reusable custom methods
static or instance.
static are usable in main static method
instance are usable in custom methods
Back
Nested If Else Statement
Front
Acceptable to write an if within an if
when block is completed all remaining conditional expressions are skipped or bypassed.
No restrictions on the depth of nesting
Back
While Statement
while (conditional expression)
statements (s);
Front
aka a loop condition
returns a Boolean result
no semi colon after condition expression
Back
Initialization, test and update for statements
floating point variables can be used
Front
compound initialization
no initialization
no conditional expression
compound update
//null loop body **
//compound test( conditional expression)