Getting Started with Java Using Alice. 1 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Similar documents
Getting Started with Java Using Alice. 1 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Decision Structures. Chapter 4

Variables and Functions Chapter 3

Alice. Coverage. Mathematical Expressions, Conditional Statements, Control Structures. Arithmetic Expressions Built-in Functions Conditional Execution

potions. The troll doubles in size.

Repetition. Add in Objects. Position Objects. Monkey Eat Bananas Repetition Simple Loops and Conditional Loops for Alice 3

Monkey Eat Bananas Repetition Simple Loops and Conditional Loops for Alice 3

Using Functions in Alice

Telling a Story Visually. Copyright 2012, Oracle. All rights reserved.

Creating Java Programs with Greenfoot

Loops and Files. Chapter 04 MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz

Duration 30 minutes Notes This tutorial was built using Alice

Introduction to Events

Repetition everywhere comparing while in a method and as an event. Comparison

An object in 3D space

Shorter of two objects and changing color V2

Database Programming with PL/SQL

Class-level Methods. Chapter 6 part 1

The Oracle Academy Supports 1.5 million students in 95 countries

Changing Camera Views! Part 2: Simple Scene Change & Lighting Fixes

Programming Fundamentals

Beginning Programming (Two Semesters) Semester One. Module One: Intro to Beginning Programming. Module Two: Computer Careers

Chapter 1 Objectives. Today s Agenda. What is a Computer Program? Chapter 1: Introduction to Alice and Objects

Creating a Fancier Fox and Inheritance in Alice 3

Creating Java Programs with Greenfoot

Methods (part 2) Alice In Action, Ch 2

Gaddis: Starting Out with Alice Test Bank Chapter One 1 Chapter One

Events (Alice In Ac.on, Ch 6)

The Whyline. An Interrogative Debugging Interface for Asking Questions About Program Behavior. Andrew J. Ko and Brad A. Myers

Software Development Techniques. December Sample Examination Paper. Time: 3 hours

Creating Java Programs with Greenfoot

Shorter of two objects and changing color

Burning Laser. In this tutorial we are going to use particle flow to create a laser beam that shoots off sparks and leaves a burn mark on a surface!

The Alice Scene Editor

Name Introduction to Computer Science. 1. A sequence of instructions that tell the computer what to do is known as a?

Outline. Debugging. In Class Exercise Solution. Review If Else If. Immediate Program Errors. Function Test Example

Loops. Upsorn Praphamontripong. CS 1110/CS 1111 Introduction to Programming Spring 2018

The Essentials of Alice

CompSci 94 Making Decisions February 8, Prof. Susan Rodger

Chapter 3. Iteration

Events (Alice In Action, Ch 6)

College Board. AP CS A Labs Magpie, Elevens, and Picture Lab. New York: College Entrance Examination Board, 2013.

Introduction to Computer Science with Python Course Syllabus

Plotting Points. By Francine Wolfe Professor Susan Rodger Duke University June 2010

Kids College Computer Game Programming Exploring Alice 3.X and Object-Oriented Programming

Chapter 2 Motion. Now consider a horizontal pipe running through it (left to right). Now, a vertical pipe (top to bottom) runs through the same point.

Creating Java Programs with Greenfoot

Autodesk Navisworks Freedom Quick Reference Guide

Alice 3 Workshop. CS & IT Irvine, CA July 9, Copyright 2012 Wanda Dann, Don Slater, Steve Cooper

Methods (part 1) Alice In Action, Ch 2

How Do Robots Find Their Way?

Chapter 0. Getting Started. Objectives

S3 Scratch Programming

Making Objects Move in Unison: Using Lists. Overview

Making Objects Move in Unison: Using Lists

Teaching Kids to Program. Lesson Plan: Catch the Ball

Digital Ink and Paint Week 5. Animation: Animated Symbols, Graphic Symbols vs Movie Clip Symbols, Bones, 3D Translation

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Alice: A Free 3D Animation World for Teaching Programming

Recognizing a Function

In this lesson you will learn: To use various tools of Paint activity. (See the level I lesson on paint for a revision.)

Chapter 5. Creating Special Effects Delmar, Cengage Learning

Table of Contents WINDOWS 95. What is Windows 95? Features LINC TWO

Lesson 2 Fractions on a Number Line

Topic: Conics Verify the solution to a linear-quadratic system of equations by graphing and using Intersection Point(s).

Up in the air (PC/Mac)

The City School PAF Chapter Comprehensive Worksheet April 2018 ICTech Class 7 Candidate Name: Index Number: Section: Branch/Campus: Date:

Appendix A Reference: Built-in Methods

(Refer Slide Time: 01:40)

Crossley Fields - Computing Vocabulary

Objects. Welcome to Programming with Alice and Java. If you re CHAPTER CHAPTER OBJECTIVES

CSCI 150: Exam 1 Practice

Boardmaker 5.0 (Macintosh) Creating a Story Response Board. Introduction. Case Study. Learning Objectives

COMSC-031 Web Site Development- Part 2

Revit Architecture. So you want to start a family? Veronica Lamb S2-2


Animation Charts. What is in the Animation Charts Package? Flying Cycle. Throw Side View. Jump. Side View. Sequence Layout

Workshop BOND UNIVERSITY Bachelor of Interactive Multimedia and Design Beginner Game Dev Character Control Building a character animation controller.

OpenMind 2 New Document Open Document Mind Map Top Down Left Right Top Down Left Right Timeline Timeline Outline

Unit E Step-by-Step: Programming with Python

While Loops A while loop executes a statement as long as a condition is true while condition: statement(s) Statement may be simple or compound Typical

BIOC351: Proteins. PyMOL Laboratory #4. Movie Making

UDK Basics Textures and Material Setup

The City School PAF Chapter Comprehensive Worksheet April 2018 ICTech Class 7 Candidate Name: Index Number: Section: Branch/Campus: Date:

Curriculum Map Grade(s): Subject: AP Computer Science

In this project, you ll learn how to use CSS to create an animated sunrise.

CMSC/BIOL 361: Emergence Cellular Automata: Introduction to NetLogo

1. The PowerPoint Window

The Oracle Academy Introduction to Computer Science

Lines of Symmetry. Grade 3. Amy Hahn. Education 334: MW 8 9:20 a.m.

animation, and what interface elements the Flash editor contains to help you create and control your animation.

How to create text and graphics with the

Princess & Dragon Part 1: Objects in an Alice World

About Course Builder

Appendix E: Software

AN INTRODUCTION TO SCRATCH (2) PROGRAMMING

Flow Control: boolean expressions, if selec5on statements (Alice In Ac5on, Ch 4)

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Gaddis: Starting Out with Alice Test Bank Chapter Two 1 Chapter Two

Transcription:

Getting Started with Java Using Alice 1 Copyright 2013, Oracle and/or its affiliates. All rights

Objectives This lesson covers the following objectives: Use the IF control structure to effect execution of instructions Use the WHILE control structure to create a conditional loop for repetitive behavior 2 Copyright 2013, Oracle and/or its affiliates. All rights

Control Structures Control structures are pre-defined statements that determine the order in which programming instructions are executed. You should be familiar with the Do together and Do in order control structures from previous topics. 3 Copyright 2013, Oracle and/or its affiliates. All rights

Control Structures Available in Alice 3 Available pre-defined control structures include: Do in order Count While For each in While Do together Each in together 4 Copyright 2013, Oracle and/or its affiliates. All rights

Control Structures Display You can drag a control structure to myfirstmethod before or after creating the programming instructions that will be included in the control structure. 5 Copyright 2013, Oracle and/or its affiliates. All rights

Control Structures Example For example, if you create a move and turn instruction for an object, and later decide that the actions should execute simultaneously, you can insert a Do together control structure and reposition the move and turn instructions within the control structure. Or, you can anticipate that you are going to need a Do together control structure, insert the control structure, and then create and position the programming instructions within the control structure. 6 Copyright 2013, Oracle and/or its affiliates. All rights

Nesting Control Structures Control structures may be nested, meaning that one structure is contained within another. For example, if a person is going to wave his left hand and then his right hand while he is moving forward, nested control structures would be necessary. 7 Copyright 2013, Oracle and/or its affiliates. All rights

Nesting Control Structures Code Example Examine the programming instructions below. 8 Copyright 2013, Oracle and/or its affiliates. All rights

Conditional Execution Using Control Structures Conditional control structures allow you to control execution based on a condition, or a decision being made. Consider these examples: If the current color of an object is blue, change the color to orange. If the width to the rock is less than 1 meter, move forward 1/2 meter. If the object opacity is 0, change the opacity to 1. 9 Copyright 2013, Oracle and/or its affiliates. All rights

IF Control Structure The IF control structure requires a condition of true or false when the structure is dragged into the program. This initial condition is a placeholder. You will need to establish the condition to be evaluated. 10 Copyright 2013, Oracle and/or its affiliates. All rights

IF Control Structure Parts The IF control structure has two parts: the IF part, and the ELSE part. If the IF part is executed, the ELSE part is never executed. If the ELSE part is executed, the IF part is never executed. Both the IF part and the ELSE part of an IF statement can contain another nested IF control structure. 11 Copyright 2013, Oracle and/or its affiliates. All rights

WHILE Control Structure The WHILE statement executes instructions repeatedly in a loop while a condition is true. This conditional execution is also known as repetition. The WHILE condition: Acts like a gatekeeper to an event. Must be true to allow the programming instructions within the loop to execute. 12 Copyright 2013, Oracle and/or its affiliates. All rights

WHILE Control Structure and Repetitive Execution After all of the programming instructions within a loop are executed, the WHILE condition is evaluated again for repetitive execution. If the condition is still true, execution will repeat. If the condition is false, the loop will be skipped and execution will continue with the next programming statement following the WHILE control structure. 13 Copyright 2013, Oracle and/or its affiliates. All rights

Interpret an IF Control Structure An IF control structure is a decision based on a condition. Example condition: If it rains today I will wear a raincoat. Otherwise, I will wear a sweater. IF control structures can be interpreted using a process flow. A process flow is a graphical representation of a process model. Process flows use shapes to represent the actions in the model. 14 Copyright 2013, Oracle and/or its affiliates. All rights

IF Control Structure Process Flow If it rains today, then I will wear a raincoat. Otherwise, I will wear a sweater. True If it rains today, then False Do this: Wear raincoat Do this: Wear sweater End 15 Copyright 2013, Oracle and/or its affiliates. All rights

IF Control Structure Process Flow Example If the cat walks into the dog, then the cat says Excuse me! Otherwise, the cat continues walking. True If cat collides with dog False Do this: Cat says, Excuse me! Do this: Cat continues to walk End 16 Copyright 2013, Oracle and/or its affiliates. All rights

Steps to Program an IF Control Structure 1. Insert the initial motions that happen before the IF control structure is executed. 2. Drag and drop the IF control structure into the Code editor and select the true condition as a placeholder during setup. 3. Replace the true condition with a condition to evaluate, such as a function. 4. Insert the procedures that t will execute if the condition is true (IF) and those that will execute if the condition is false (ELSE). 5. Run the animation to test the conditional behavior. Debug as necessary. 17 Copyright 2013, Oracle and/or its affiliates. All rights

IF Control Structure Example If the cat collides with the dog, then the cat moves backward and says Excuse me! Otherwise, the cat continues to move forward. The iscollidingwith function was dragged onto the true condition placeholder. This function tells us if one object is colliding with another. 18 Copyright 2013, Oracle and/or its affiliates. All rights

Conditional Execution The use of conditional control structures allows two types of loops: Conditional loop: Stops when a condition is true. Example: The propeller of a helicopter turns while the helicopter is moving or flying. If the helicopter stops, then the propeller stops turning. Infinite loop: Never stops. The hour and minute hands on a clock continue rolling. 19 Copyright 2013, Oracle and/or its affiliates. All rights

WHILE Control Structure The WHILE control structure performs conditional loops. While a condition is true, the programming instructions within the loop are executed. Once the condition is no longer true, program execution will skip the WHILE condition and continue with the programming instruction that follows the WHILE loop. The WHILE control structure will perform instructions while a condition is true; otherwise it will bypass the instructions. 20 Copyright 2013, Oracle and/or its affiliates. All rights

WHILE Control Structure Process Flow The Queen moves forward, unless she collides with the Playing Card. If the Queen collides with the Playing Card, she stops and turns to face the camera. True While the Queen is collision-free False Queen moves forward Queen stops and turns around End 21 Copyright 2013, Oracle and/or its affiliates. All rights

Steps to Program a WHILE Control Structure 1. Drag and drop the WHILE control structure into the Code editor and select the true condition as a placeholder. 2. Replace the true condition placeholder with the condition to evaluate. 3. Insert procedures that will be executed while the condition is true. 4. Insert the procedures that are executed after the while loop stops executing. 22 Copyright 2013, Oracle and/or its affiliates. All rights

WHILE Control Structure Example Code While the Queen is not colliding with the Playing Card, the Queen moves forward repeatedly. If the Queen does collide with the Playing Card, the WHILE loop stops and the program continues with the next instruction: she stops and turns to face the camera. 23 Copyright 2013, Oracle and/or its affiliates. All rights

Steps to Test a WHILE Control Structure 1. Position objects such that the WHILE condition will evaluate to true. 2. Observe that all programming instructions within the WHILE loop execute. 3. Ensure that the WHILE loop execution stops when the while condition is no longer true. 24 Copyright 2013, Oracle and/or its affiliates. All rights

Summary In this lesson, you should have learned how to: Use the IF control structure to effect execution of instructions Use the WHILE control structure to create a conditional loop for repetitive behavior 25 Copyright 2013, Oracle and/or its affiliates. All rights