Software Programming and FundamentalsRecap what we covered in week #1
VariableVariable:  imagine like a box to store one thing (data)Eg: int age;         age = 5;
VariableVariable:  imagine like a box to store one thing (data)Eg: int age;         age = 5;int - Size of variable must be big enough to store Integer
VariableVariable:  imagine like a box to store one thing (data)Eg: int age;         age = 5;int - Size of variable must be big enough to store Integerage - Name of variableage
VariableVariable:  imagine like a box to store one thing (data)Eg: int age;         age = 5;5int - Size of variable must be big enough to store Integerage - Name of variableageage = 5 – Put a data 5 into the variable
Value Type Vs Reference TypeVariables:  two typesValue type (simple type like what you just saw)Only need to store one thing (5, 3.5, true/false, ‘C’ and “string”)Reference type (complex type for objects)Need to store more than one thing (age + height + run() + … )
Reference TypeReference type (complex type for objects)Eg: Human john;         john = new Human();Compare this to int age;age = 5;
Reference TypeReference type (complex type for objects)Eg: Human john;         john = new Human();Human - Size of variable must be big enough to store an Address
johnReference TypeReference type (complex type for objects)Eg: Human john;         john = new Human();Human - Size of variable must be big enough to store an Addressjohn - Name of variable
Reference TypeReference type (complex type for objects)Eg: Human john;         john = new Human();D403age…Human - Size of variable must be big enough to store an Addressheightjohn - Name of variablejohnjohn = new Human() – Get a house with enough space for john (age, height, etc)
Non-Static Vs Static ClassNon-Static: need New() to instantiate / create an object – like what you see just nowStatic: no need to use New() to use, there is just one copy of the class.  This type of class basically to provide special functions for other objects  So if you see a class being used without New(): it is a static classEgMath class   age = Math.Round(18.5);  // Math rounding
Using Console Program for problem solvingConsole program:SimpleProcedural (from top to bottom)Getting inputs:  From arguments: How?  From keyboard:    How?Exercise 2.1 – 2.5Language fundamental: int, double, string, Console.WriteLine(), Console.Write(), Console.ReadLine(), int.Parse(), double.Parse(), simple if then statementProblem solving: repeating, swopping of 2 variables, simple sorting

Variables - Value and Reference Type

  • 1.
    Software Programming andFundamentalsRecap what we covered in week #1
  • 2.
    VariableVariable: imaginelike a box to store one thing (data)Eg: int age; age = 5;
  • 3.
    VariableVariable: imaginelike a box to store one thing (data)Eg: int age; age = 5;int - Size of variable must be big enough to store Integer
  • 4.
    VariableVariable: imaginelike a box to store one thing (data)Eg: int age; age = 5;int - Size of variable must be big enough to store Integerage - Name of variableage
  • 5.
    VariableVariable: imaginelike a box to store one thing (data)Eg: int age; age = 5;5int - Size of variable must be big enough to store Integerage - Name of variableageage = 5 – Put a data 5 into the variable
  • 6.
    Value Type VsReference TypeVariables: two typesValue type (simple type like what you just saw)Only need to store one thing (5, 3.5, true/false, ‘C’ and “string”)Reference type (complex type for objects)Need to store more than one thing (age + height + run() + … )
  • 7.
    Reference TypeReference type(complex type for objects)Eg: Human john; john = new Human();Compare this to int age;age = 5;
  • 8.
    Reference TypeReference type(complex type for objects)Eg: Human john; john = new Human();Human - Size of variable must be big enough to store an Address
  • 9.
    johnReference TypeReference type(complex type for objects)Eg: Human john; john = new Human();Human - Size of variable must be big enough to store an Addressjohn - Name of variable
  • 10.
    Reference TypeReference type(complex type for objects)Eg: Human john; john = new Human();D403age…Human - Size of variable must be big enough to store an Addressheightjohn - Name of variablejohnjohn = new Human() – Get a house with enough space for john (age, height, etc)
  • 11.
    Non-Static Vs StaticClassNon-Static: need New() to instantiate / create an object – like what you see just nowStatic: no need to use New() to use, there is just one copy of the class. This type of class basically to provide special functions for other objects So if you see a class being used without New(): it is a static classEgMath class age = Math.Round(18.5); // Math rounding
  • 12.
    Using Console Programfor problem solvingConsole program:SimpleProcedural (from top to bottom)Getting inputs: From arguments: How? From keyboard: How?Exercise 2.1 – 2.5Language fundamental: int, double, string, Console.WriteLine(), Console.Write(), Console.ReadLine(), int.Parse(), double.Parse(), simple if then statementProblem solving: repeating, swopping of 2 variables, simple sorting