Lesson 5: Building an App: Clicker Game

Slides:



Advertisements
Similar presentations
An Introduction to Programming with C++ Fifth Edition
Advertisements

Topic 4 – Programmer- Defined Functions. CISC 105 – Topic 4 Functions So far, we have only seen programs with one function, main. These programs begin.
2015 Pre-Release Practice Click the button to try a random exam-style question. Click on the reveal button to check your answer.
Software design and development Marcus Hunt. Application and limits of procedural programming Procedural programming is a powerful language, typically.
JS Arrays, Functions, Events Week 5 INFM 603. Agenda Arrays Functions Event-Driven Programming.
Beginning C++ Through Game Programming, Second Edition by Michael Dawson.
National Diploma Unit 4 Introduction to Software Development Data types, variables and constants.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
Current Assignments Homework 2 is available and is due in three days (June 19th). Project 1 due in 6 days (June 23 rd ) Write a binomial root solver using.
David Stotts Computer Science Department UNC Chapel Hill.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
A FIRST BOOK OF C++ CHAPTER 6 MODULARITY USING FUNCTIONS.
1 Writing Software Kashef Mughal. 2 Algorithms  The term algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a problem.  An Algorithm.
Language Find the latest version of this document at
Controlling Program Flow with Decision Structures.
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
Functions in C++ Top Down Design with Functions. Top-down Design Big picture first broken down into smaller pieces.
Introduction to Arrays. Learning Objectives By the end of this lecture, you should be able to: – Understand what an array is – Know how to create an array.
JavaScript Modularity. Goals By the end of this lecture, you should … Understand why programmers use modularity. Understand how to create a function in.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are used in programs so that values can be represented with.
Object-Oriented Programming: Classes and Objects.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
EGR 2261 Unit 13 Classes Read Malik, Chapter 10.
EGR 2261 Unit 11 Pointers and Dynamic Variables
A variable is a name for a value stored in memory.
Friend functions, operator overloading
Phil Tayco Slide version 1.0 Created Sep 18, 2017
Programming the Web Using Visual Studio .NET
Object Oriented Programming
UNIT 3 – LESSON 5 Creating Functions.
Lesson 9: "if-else-if" and Conditional Logic
Lesson 10: Building an App: Color Sleuth
Lesson 2: Multi-Screen Apps
Starting Out with Programming Logic & Design
Microsoft Visual Basic 2005 BASICS
Building an App: Multi-Screen App
Lesson 8: Boolean Expressions and "if" Statements
Creativity in Algorithms
Lesson 4: Controlling Memory with Variables
Chapter 4 Functions Objectives
Lesson 17: Building an App: Canvas Painter
Lesson 16: Functions with Return Values
LESSON 13 – INTRO TO ARRAYS
Lesson 15: Processing Arrays
Repetition Structures
Coding Concepts (Sub- Programs)
Variables Numbers can be stored and retrieved while a program is running if they are given a home. The way that integers and decimal numbers are stored.
HAPPY NEW YEAR! Lesson 7: If-statements unplugged
Chapter 8 Namespaces and Memory Realities
Arduino Part #3 Variables
Lesson Objective: I will be able to …
Writing Functions.
Defining Classes and Methods
The lifespan of a variable
Chapter 9: Value-Returning Functions
ICT Gaming Lesson 3.
Topics Introduction to Functions Defining and Calling a Function
CIS16 Application Development and Programming using Visual Basic.net
Starting Out with Programming Logic & Design
Vocabulary Algorithm - A precise sequence of instructions for processes that can be executed by a computer Low level programming language: A programming.
Defining Classes and Methods
Javascript Chapter 19 and 20 5/3/2019.
Brent M. Dingle Texas A&M University Chapter 5 – Section 2-3
Chapter 13 Conditional Repetition
CIS 136 Building Mobile Apps
3.2 Working with Data Scope of variables 29/07/2019.
Variables and Constants
Intro to Programming (in JavaScript)
Scope Rules.
Presentation transcript:

Lesson 5: Building an App: Clicker Game UNIT 5 – LESSON 5

VOCABULARY ALERT: == - The equality operator (sometimes read: "equal equal") is used to compare two values, and returns a Boolean (true/false). Avoid confusion with the assignment operator "=", Global Variable - A variable whose scope is "global" to the program, it can be used and updated by any part of the code. Its global scope is typically derived from the variable being declared (created) outside of any function, object, or method. If-Statement - The common programming structure that implements "conditional statements". Local Variable - A variable with local scope is one that can only be seen, used and updated by code within the same scope. Typically this means the variable was declared (created) inside a function -- includes function parameter variables. Variable Scope - dictates what portions of the code can "see" or use a variable, typically derived from where the variable was first created. (See Global v. Local)

The major topic is variable scope and understanding the differences, benefits, and drawbacks, of using global versus local variables. This lesson focuses more on using global variables, since in event-driven apps that’s what you need to keep track of data across multiple events.

In programming, the = sign assigns something, like a value to a variable name. The == (equality symbol) COMPARES to see if the criteria listed on one side is the same as the other side. Yes or No. Boolean!

Variable scoping is a form of abstraction - a programming language lets you create variables with as narrow or broad a scope as you need to program a certain task. As a general practice, you usually want to create variables with the most narrow scope you can for the task at hand, since the other extreme - everything is global - can become unwieldy or hard to manage, and it doesn’t promote code reuse.

Recall In the previous lesson, we learned about the basic mechanics of working with variables in JavaScript. We developed a mental model for thinking about how values are stored and retrieved from memory and that we should read the “=” sign as “gets” to avoid confusion. Moving forward:  The whole purpose of learning about variables though is so that our apps can make use of them while a program is running. In this lesson, we’ll see how to do that. So let’s get to it.

This Activity Guide - The Clicker Game - Activity Guide is not strictly needed until the very end of the lesson -- it is referred to in level 21

Do the lesson in Code Studio Do the lesson in Code Studio. Don’t skip anything – learning about variable global and local scope is VITAL to your programming prowess! Make the Click It game – show it to me Partner grades it with the Activity Guide Both partners sign the Activity Guide