HOMEWORK REVIEW This is an if else statement layout if (condition) { code to be executed if condition is true; } else { code to be executed if condition.

Slides:



Advertisements
Similar presentations
VCE SD Theory Slideshows By Mark Kelly Vceit.com Debugging Techniques.
Advertisements

Programming Types of Testing.
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Debugging Introduction to Computing Science and Programming I.
If Statements Sections 1.25, Control Structures o All code thus far executes every line of code sequentially o We want to be able to repeat,
Chapter 3 Planning Your Solution
Programming – Touch Sensors Intro to Robotics. The Limit Switch When designing robotic arms there is always the chance the arm will move too far up or.
The switch Statement, DecimalFormat, and Introduction to Looping
Chapter 1: Introduction To Computer | SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005 Slide 1 Introduction To Computers.
While Loops and Do Loops. Suppose you wanted to repeat the same code over and over again? System.out.println(“text”); System.out.println(“text”); System.out.println(“text”);
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Python quick start guide
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
Introduction to Python
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Chapter 2 - Algorithms and Design
Developing an Algorithm
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
USING UNITY JAVASCRIPT. CONVENTIONS AND SYNTAX IN JAVASCRIPT Case Sensitivity All keywords like var or function must be in lowercase. All variable names,
1 Chapter 2 - Algorithms and Design print Statement input Statement and Variables Assignment Statement if Statement Flowcharts Flow of Control Looping.
Coding Design Tools Rachel Gauci. Task: Counting On Create a program that will print out a sequence of numbers from "1" to a "number entered”. Decision’s.
USING UNITY JAVASCRIPT. CONVENTIONS AND SYNTAX IN JAVASCRIPT Case Sensitivity All keywords like var or function must be in lowercase. All variable names,
CMP-MX21: Lecture 4 Selections Steve Hordley. Overview 1. The if-else selection in JAVA 2. More useful JAVA operators 4. Other selection constructs in.
Review, Pseudocode, Flow Charting, and Storyboarding.
Conditional Statements.  Quiz  Hand in your jQuery exercises from last lecture  They don't have to be 100% perfect to get full credit  They do have.
Problem Solving Methodology Rachel Gauci. Problem Solving Methodology Development Design Analysis Evaluation Solution requirements and constraints. Scope.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Controlling Program Flow with Decision Structures.
Efficiently Solving Computer Programming Problems Doncho Minkov Telerik Corporation Technical Trainer.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
Learning Javascript From Mr Saem
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Harvard Mark I Howard Aiken was a pioneer in computing and a creator of conceptual design for IBM in the 1940s. He envisioned an electro-mechanical computing.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. 4 Simple Flow of Control.
BIT116: Scripting Lecture 05
JavaScript Controlling the flow of your programs with ‘if’ statements
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Chapter 10 Programming Fundamentals with JavaScript
Selection (also known as Branching) Jumail Bin Taliba by
Control Structures II Chapter 3
The switch Statement, and Introduction to Looping
Debugging and Random Numbers
IF statements.
The Selection Structure
If, else, elif.
Scripts & Functions Scripts and functions are contained in .m-files
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Chapter 10 Programming Fundamentals with JavaScript
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
We’re moving on to more recap from other programming languages
Selection Statements.
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
ECS15 while.
Flowcharts and Pseudo Code
IPC144 Introduction to Programming Using C Week 4 – Lesson 2
If-Statements and If/Else Statements
Review of Previous Lesson
Lab 8: GUI testing Software Testing LTAT
Software Development Techniques
IPC144 Introduction to Programming Using C Week 2 – Lesson 2
Primary School Computing
How to allow the program to know when to stop a loop.
CHAPTER 6 Testing and Debugging.
Presentation transcript:

HOMEWORK REVIEW This is an if else statement layout if (condition) { code to be executed if condition is true; } else { code to be executed if condition is false; } Complete the following (this can be done in your Google drive or on paper and brought to class): “ TOPIC: Create an IF ELSE statement that gives a result of “pass” or “fail” with the pass mark of 50.” 1.Create a Pseudocode to help ‘plan’ your if else statement (Look at slide 10 for an example) 1. Create an IF ELSE statement in this Unity beginning script (decide whether to put it in function start or function update (if you get stuck look at slide 12)

THIS IS THE TEMPLATE FOR YOUR HOMEWORK #pragma strict function start () { } function update () { } If wanted to have the code execute one time only, then you will need to put you IF ELSE statement in the function start area. All script needs to sit inside the { } All script in the function update will have the opportunity to run over and over for as long as the script inside the { } wants to

LETS TRY ONE OURSELVES Using Unity JavaScript create a Pseudocode to help ‘plan’ your if else statement. “ TOPIC: Create an IF ELSE statement that gives a result of “pass” or “fail” with the pass mark of 50. Pseudocode (coding design tool, helps me visualize what I want in my script) IF MARK >= 50 THEN PRINT “You pass” ELSE PRINT “You fail” END IF

MY ANSWER EXAMPLE #pragma strict var mark= 75; function Start() { if (mark >= 50) { Debug.Log ("You pass"); } else { Debug.Log("You fail"); } } function Update() { } I have created my variable, naming it ‘mark’ I gave it some information/value mark=75. So now whenever I type the word mark in my script the value 75 will replace the word. IF mark is greater than or equal to 75 then the computer console will print ‘You pass’ Else/ otherwise (if the input is less than 50) print ‘You fail’ to the computer console.

DEBUGGING

WHERE DID THE TERM DEBUGGING COME FROM? On September 9th, 1947 a woman, Grace Hopper, was working on a computer at Harvard University. The computer was one if those main frame computers that were very large. When the computer stopped working, she began to investigate the problem. After removing one of the panels she found a moth caught between two relay points. When she removed the moth and put the panel back in place, the computer functioned properly again. Grace reported that the computer was debugged.

DEBUGGING What is debugging in programming? Debugging means to check and test your script/work and ensure that is it doing what was planned without any faults, so that you correctly achieve your purpose. Debugging is looking for errors in the script that: 1.Stop the script or part of from working e.g. misspelling a function/variable name, therefore the code cannot be executed. 2.The script works but what you wanted the script to achieve in fact doesn’t. e.g. “” where not included therefore the script will play but the information you wanted to appear on screen won’t because there is an error

WHAT COULD WE BE LOOKING FOR? Check all possible processing pathways through the program, if I have an IF statement that needs to print x when the user puts in y does this happen?. Also the visual interface needs to be tested (that is testing that what you expect to see is what you in fact see). Lastly does what you planned suit your original expectations? Simple syntax errors in JavaScript to look out for: -Brackets are in the right place and the correct bracket was used either () or {} or [] -Capital and lower case letters are correct -When referring to a variable is it spelt correct and has the right upper and lower case setup -Are there ; (semi colons) either in the wrong place or missing -Do you need to space where there isn’t one -Have you used the right symbols > < + = - // # “” -AND MANY MORE (refer to page 239 of Information technology textbook)

HOW TO DEBUG There are a few ways to check for errors. 1.Play the script and view the result. 2.Scan through the script and look for missing content 3.Take all of the script out and replace it a bit at a time, while playing the script (add script press play, add script press play etc. does each part work) 4.Use debugging software (e.g. Unity has its own) You simply put your script in and the program will check for particular errors. 1.Record a test table and keep a record…

Test DataExpectedActualComments The section of data that is tested What to expect the result of this What actually happened Where there any changes you made to ‘fix’ the issues. If there weren’t note that and include why it doesn't’t need to be fixed etc. TESTING TABLE Testing tables are like keeping a checklist; writing it in table form keeps the information relevant and neat. Types of testing include: Input testing, data-validation testing, process testing, output testing and storage testing

IF/ELSE COFFEE SCRIPT #pragma strict var coffeeTemperature:float = 85.0f; var hotLimitTemperature:float = 70.0f; var coldLimitTemperature:float = 40.0f; function Update() { if(Input.GetKeyDown(KeyCode.Space)) TemperatureTest(); coffeeTemperature -= Time.deltaTime * 5f; } function TemperatureTest() { // If the coffee's temperature is greater than the hottest drinking temperature... if(coffeeTemperature > hotLimitTemperature) { //... do this. Debug.Log("Coffee is too hot."); } // If it isn't, but the coffee temperature is less than the coldest drinking temperature... else if(coffeeTemperature < coldLimitTemperature) { //... do this. Debug.Log("Coffee is too cold."); } // If it is neither of those then... else { //... do this. Debug.Log("Coffee is just right."); }

FOR LOOPS FOR LOOPS circle through a block of code and will continue to repeat the code according to the amount of times requested. Therefore instead of writing the same code over and over with one slight change, FOR loops re read and execute the code for you. Format: (set initial variable; condition; action on the variable) (rule)

EXAMPLE - LOOPING (FOR) #pragma strict var numEnemies : int = 3; function Start () { for(var i : int = 0 ; i < numEnemies ; i++) { Debug.Log("Creating enemy number: " + i); } (set initial variable; condition; action on the variable)

WHILE LOOPS While Loops are very similar to FOR loops as they too execute the same code over and over. However they differ in that WHILE loops are used when the programmer is unsure how many times they want the code to be executed. Format: while (condition/expression) { Statement/s to be executed if expression is true }

#pragma strict var numEnemies : int = 3; function Start () { while (i < 10) { Debug.Log ( "The number is " + i); } }