Week 1/2
by Pat Fantastique
1. Variables
1.1. E.g. int age, string name, double weight
1.2. Used to remember stuff
1.3. Stored short-term memory
1.4. Only exist within the current method
2. Methods
2.1. Coded to do things
2.2. Each program must contain a main method, which is static, for the program to run
2.2.1. E.g. public static void Main()
2.3. Describes one task the object or class can perform
2.4. Each method should contain a small amount of tasks
2.5. Bigger methods are broken down into smaller parts
2.6. Public method
2.6.1. Accessible by other methods
2.7. Private method
2.7.1. Can only be accessed by code in the same class
2.8. Void indicates the method will not return a value
2.9. Must code a return statement at the end of a method
3. Constructors
3.1. Initialise an object when it is created
3.2. Able to add parameters to a constructor to allow the caller to provide values
3.3. Default constructors
3.3.1. Have no parameters that initialise an objects default values
4. Statements
4.1. Variable Declaration
4.1.1. Used to create a variable to remember something later
4.2. Assignment Statement
4.2.1. Stores a value in a variable
4.3. Method Call
4.3.1. Gets the object to run instructions within called method
4.3.2. Expression
4.3.2.1. A calculated value
4.3.3. Sequence
4.3.3.1. The order in which the program will run
5. Parameters
5.1. These are things you pass in to let the function do whatever it was designed to do
5.2. Special variable within a method to allow the caller to pass values into it
5.3. public int Add(int x, int y) { return x + y; } int a = 5; int b = 5; int sum = Add(a, b);
6. Properties
6.1. Must be declared within a class
6.2. Combination of two methods, one to get the value, the other, to set the value
6.2.1. private string name; public string Name { get { return this.name; } set { this.name = value; } }
6.3. Can be read-only if there is only a get accessor
6.4. Can be read only if there is only a set accessor
7. Artefacts
7.1. Code that is declared (created).
7.1.1. Compiler (msys) must be able to find declared code.
8. Actions
8.1. Instructions that command the computer to perform an action.
8.1.1. e.g. Console.WriteLine("Hello World!");