ISY00245 Principles of Programming. Module 7
|
|
- Miles Lester
- 5 years ago
- Views:
Transcription
1 ISY00245 Principles of Programming Module 7
2 Module 7 Loops and Arrays Introduction This week we have gone through some of the concepts in your lecture, and will be putting them in to practice (as well as elaborating on them) in this study guide. If you have not watched the lecture yet, you should watch it now before starting on this work. Note that it is assumed that you have completed the work up until this point, and are familiar with creating objects, adding code, using setimage and other Greenfoot class and object methods. If you have not completed the work up until now, please go back and make sure you are familiar with it all, before going further. We will put the new concepts from the lecture into practice by building a piano application that you can play with your computer keyboard. Note that your portfolio activity this week will not be the piano scenario but will be another related scenario. You will need to apply the techniques you learn in the piano scenario, so work through those activities, and then build your portfolio scenario. Study materials Materials required: The free Greenfoot programming environment; Files in "Module07" folder on MySCU site; "Introduction to Programming with Greenfoot" textbook and support files; Internet access to access your lecture, and any other material. ISY00245 Module 7 - Page 1
3 Objectives On completion of this topic, you should be able to: implement the concept of states implement, initialise and use state variables use and construct more complex conditional statements use constructor parameters to set initial values use constructor overloading create and use while loops create, initialise and use arrays trace loops using counters and arrays Concepts state variables &&! constructor parameters while arrays array elements indices escape character tracing code abstraction ISY00245 Module 7 - Page 2
4 The piano scenario We will start with opening the existing piano-1 scenario. It has the sound files we will need, and the images, and not much else. Activity 7-1 The scenario (from Chapter 6 in your text) Open the scenario piano-1 from the book projects, and open the Key and Piano classes in the editor. Write down a short description of the methods in the Key class: Create an object of class Key and place in the world. We will later create several of them and place next to one another, as a piano keyboard. Activity 7-2 Animating the key (from Chapter 6 in your text) Add an if else construct that sets the image to "white-key-down.png" if the "g" key on the computer keyboard is pressed, and otherwise sets the image to "white-key.png". (The code, if you are stuck, is inserted after activity 7.3). Test your code by running, and pressing "g". Add a couple more piano keys and check that it works for all keys. What does this code do if the g key is not pressed, each time the act method is called? States If you answered the question above "it changes it to the same image ("white-key.png") each time" then you were correct. This means that Greenfoot is changing the image even when it doesn't need to do so. Writing what we want to actually happen in pseudocode: IF the piano key isn t down AND the g key is pressed THEN END IF change the image to white key down IF the piano key is down AND the g key isn t pressed THEN END IF change the image to white key up (normal) It becomes obvious that we need to store some information about whether the piano key is down or not. We can do this using a state variable. ISY00245 Module 7 - Page 3
5 A state variable is just a normal variable, but it stores some information about the state of something in the application. This state is then used to make some decisions about actions in the code. In this case, we want to store whether the piano key is already up or down, so we can make a decision about whether to swap the image. A sensibly named variable would be isdown. We can declare it initially (in the constructor) as false and then change the state if we need to change the image. Our pseudocode becomes IF not isdown AND the g key is pressed THEN END IF change the image to white key down set isdown to true IF the piano key is down AND the g key isn t pressed THEN END IF change the image to white key up (normal) set isdown to false Activity 7-3 Using states (from Chapter 6 in your text) 1. Add a new private boolean variable to your class called isdown. 2. Initialise this variable to false in the constructor 3. To alter our IF ELSE code to match the pseudocode above, we need to know how to implement "NOT" and "AND" in our conditions. The next section will cover this briefly. The code for Activity 7-2 is: if ( Greenfoot.isKeyDown("g") ) setimage("white-key-down.png"); else setimage("white-key.png"); More complex conditions -! and && Up until now we have been using expressions in our conditions that included < <= => > == We will now add a couple of symbols to our repertoire. Firstly,! means NOT and reverses the value of the condition. For example:!(6 > 3) would equate to false, as 6>3 is true, and the NOT operator reverses the result. && chains two conditions together, and is only TRUE if both of them are true. ISY00245 Module 7 - Page 4
6 For example: (6 > 3) && (17 < 18) would equate to true as both 6>3 and 17<18 are true. (6 < 3) && (17 < 18) would equate to false, because one of the conditions is false. (6 < 3) && (17 > 18) would also be false, because both of the conditions are false. The whole condition will only be true IF both conditions are true. Activity 7-4 Implementing our code: You have a boolean variable called isdown, which is initially false. You have pseudocode that shows the logic of how this code will be implemented. Change your act method to code that implements the following pseudocode: IF not isdown AND the g key is pressed THEN END IF change the image to white key down set isdown to true IF the piano key is down AND the g key isn t pressed THEN END IF change the image to white key up (normal) set isdown to false Test your code. It will not seem to do anything different at this stage, but we are now using less processing power, and setting this up for further steps in our application development. [If you are stuck, the code is given after Activity 7.5] The play method The next step is to produce the sound to play the note. We are going to create a new play() method in the Key class, that will play a sound. In this scenario, there are a number of sound files included in the sounds subfolder. The names of these sound files are 2a.wav, 2b.wav, 2c.wav, 2c#.wav etc. We will pick a note 3a.wav to play for the test key. From previous modules you know that you can play a sound by using the playsound method from the Greenfoot class. Activity 7-5 The play method With the scenario open, add a new public method play() to the Key class, that does not return a value. Make sure you comment it before the first line of the method. Add code to this method to play the 3a.wav sound. ISY00245 Module 7 - Page 5
7 Add code to your act method (in the right place) to call your new method. To call your new play method, use the code play(); Test your work. What happens when you create two keys, and run the scenario, and press the g key? Watch the screencast 0701 Setting up one key, in the Module 07 folder. In your textbook, read pages 103 to 108 (down to "Abstraction: creating multiple keys"). Creating Multiple Keys Previously in Module 6 we came across a situation where we wanted to use one method, with various values when we wanted to add points to the Score. We achieved this using parameters. We can do the same with constructor methods, to create objects of the same type/class with different initial values for variables. For the piano key, we would like each key to have a different name (associated with the computer keyboard), and a different soundfile associated with it. We can do this by declaring two new instance variables, key and sound, and then setting them with the constructor in the following way: public class Key extends Actor private boolean isdown; // state of this key private String key; private String sound; // key name // sound file name /** * Create a new key linked to a given keyboard key, and with * a given sound */ public Key(String keyname, String soundfile) key = keyname; sound = soundfile; isdown = false; // more methods go here We could now change the rest of our code so it uses key instead of g and sound instead of 3a.wav. ISY00245 Module 7 - Page 6
8 Activity 7-6 Abstracting the key With the scenario open, implement the changes so far - that is, add fields for the key and sound file, and change the constructor to have two parameters that initialise those fields. Modify the rest of your code so your key object reacts to the key and plays the sound file. Test it out. You will notice when you construct new keys, you need to specify the keyname and soundfile. Construct multiple keys with different sounds. Our next step is to write some code to construct the keys for us. Building the piano If you recall in Module 6, we created viruses, red cells and borders using the new keyword and addobject to add them to the world. To create a new key, we can use the expression new Key( g, 3a.wav ) and then we would have to add it to the world using the addobject code: addobject(some-object, x, y); If you remember, we can shortcut this by typing: addobject(new Key( g, 3a.wav ), 300, 180); which will create a new Key object and place in the world at coordinators (300, 180). The constructor of our piano class can be used to initially create the Keys of our piano. Activity 7-7 Beginning to build the piano 1. Add code to your piano class so it automatically creates a piano key and places it in the world. The key should trigger on "g" and play 3a.wav. 2. Change the y-coordinate so that the piano key appears exactly at the top of the piano. ISY00245 Module 7 - Page 7
9 (Hint: the key image is 280 pixels high and 63 pixels wide). 3. Write code to create a second key that plays a middle-g (2g.wav) when the f key is pressed on the computer keyboard. Place this key exactly to the left of the first key without any gap or overlap. 4. In the Piano class, refactor your constructor by creating a new method called makekeys(). Move the code that creates your keys into this method. Call the method from the Piano's constructor. Make sure you write a comment for your new method. The While Loop The while loop was covered in the lecture for this module. It is the first loop we will look at for the Java programming language. A while loop has the following form: while (condition) statement; statement;... If we would like to execute a loop a number of times, then we declare a counting variable outside (before) the loop, and then change the value stored in the variable in some way inside the loop. When the condition becomes false, the loop will stop. For example: int counter = 0; while (counter < 100) // do something here counter = counter + 1; The counter is very important in this sort of loop. If we don't change the value of the counter within the loop, then the loop condition will never be false - and we will have an infinite loop. We can use this construct to create our 12 piano keys. A good start may be: int i = 0; while (i < 12) addobject(new Key( g, 3a.wav ), 300, 140); i = i + 1; We can now replace the code in the makekeys method with this loop. Activity 7-8 Using a loop Replace the code in the makekeys method. Test - what did you observe? ISY00245 Module 7 - Page 8
10 We can ensure that the keys do not all appear at the same place by using the loop counter i as a variable in our addobject code. A good start would be addobject(new Key( g, 3a.wav ), i*63, 140); as the piano key images are 63 pixels wide. If you implement this, you will see that the first time through the loop, the key will be placed at (0, 140). The second time through the loop, the next key will be placed at (63,140), and so on. Unfortunately, our image coordinates are at the centre of the keys, so our left-most key is half off the keyboard. We can fix this by adding an offset amount. addobject(new Key( g, 3a.wav ), i* , 140); Activity 7-9 Adding all the white keys Replace the code in the makekeys method with our loop code. Test - what did you observe? ISY00245 Module 7 - Page 9
11 Optional: Using the fixed numbers for images in our code this way is not optimal. If something changes, such as the size of the images we are using, then our code will break. To solve this, we can use the getwidth() and getheight() methods of the key s image. To do this, assign the key object to a local variable of type Key when you create it, then use key.getimage().getwidth() to find the width and similar for the height. You can replace the 54 by getting the width of the piano s image and doing some calculations to work out the offset. Replacing these values means that the code will always work even if the size of images change. At the moment, our keys all react to the g key on the computer keyboard, and all play the same note. We would like to assign different keys and soundfiles to these piano keys as they are created. To be able to do this, we will store them in an Array. Arrays An array is an object that can hold many variables, and can be treated as one variable. You can think of it as a collection of things that have some similarity. Some of you may have come across paper expanding files that look like this: You may like to keep a mental model of an Array that looks something like this. Other people are happier to think of an Array as a set of variable spaces next to one another: Instead of each of these variable spaces having a name, the whole array has a name, and then each variable space has an index number. These indices start at 0. The figure will help you to visualise this concept. ISY00245 Module 7 - Page 10
12 (from If the array was called numbers then the highlighted element would be numbers[8]. Creating arrays To create a new array, we first tell the computer what sort of values we want to store in the array. int[] numbers; numbers = 47, 36, 20, 15 ; We can also combine the declaration and initialisation (as we have previously with other variables: double[] fractions = 0.1, 0.2, 0.25, 0.5, 0.75; String[] pets = dog, cat, rabbit, mouse, wombat ; Accessing elements We can access the element of an array by using its index. We can use this index to either get the value that is already set in the array: mydouble = fractions[2]; or to store a new value in the array element: pets[3]= horse ; As with the variables we have already encountered, setting a new value for an array element means the old value that was stored is lost. We are now in a position to set up two arrays one with the names of the computer keyboard keys we want to use (in order) for our piano keys, and one with the names of the sound files for those piano keys. Setting up and using the piano arrays Greenfoot uses a coordinate system that measures units (pixels or other measures) from the top left-hand corner. It is similar to many other IDEs in this way. The distance across the screen from the lefthand side is the x coordinate, and the distance down from the top is the y coordinate. In the Piano class, we need two array instance variables: private String[] whitekeys = a, s, d, f, g, h, j, k, l, ;,, \\ ; private String[] whitenotes = 3c, 3d, 3e, 3f, 3g, 3a, 3b, 4c, 4d, 4e, 4f, 4g ; ISY00245 Module 7 - Page 11
13 There is one thing that needs explaining in this code: the \\ in the whitekeys array. In Java the \ (backslash) character has a special meaning for Strings. It is the escape character for Java Strings. We actually want to use the \ on the keyboard, so to let Java know its actually the character, we have to place the escape character \ and then the actual character we want \. This means we end up with \\ whenever we want to use \ in a Java String variable. Now we have two arrays ready to use, we can now use the counter to loop through the loop, pointing at a different element each time. private void makekeys() int i = 0; while (i < whitekeys.length) Key key = new Key(whiteKeys[i], whitenotes[i]+.wav ); addobject(key, i* , 140); i = i + 1; This may seem a little confusing. If you ever get confused with loops and arrays, use a table to trace out the values to help you understand the code. If you have an error in your code, a trace can help you identify what has gone wrong. whitekeys.length = 12 (see the lecture for explanation of this) i i < 12 whitekeys[i] whitenotes[i]+.wav i * i = i true a 3c.wav true s 3d.wav true d 3e.wav true 11 true \\ 4g.wav false Activity 7-10 Using arrays to build the white keys Make the changes discussed above in your own scenario. Make sure that all keys work. If your keyboard layout is different, adapt the whitekeys array to match your keyboard. Now change the piano so that the keys are one octave lower than they are now. That is, use the sound "2c" instead of "3c" for the first key, and move up from there. ISY00245 Module 7 - Page 12
14 Activity 7-11 Black keys - abstraction [Exercise 6.22 & 6.23 in your text] Currently the Key class can only produce white keys. This is because we have hard-coded the filenames of the key images ("white-key.png" and "white-key-down.png"). Use abstraction to modify the Key class so that it can show either white or black keys. This is similar to what we did with the key name and sound file name: introduce two fields and two parameters for the two image file names, and then use the variables instead of the hard-coded filenames. Test by creating some black and white keys. Modify your Piano class so that it adds two black keys at an arbitrary location. Activity 7-12 Black keys - placement [Exercise 6.24 and 6.25 in your text] Add two more arrays to the Piano class for the keyboard keys and notes of the black keys. Remove the code to add two black keys and instead add another loop in the makekeys method in the Piano class that creates and places the black keys. This is made quite tricky by the fact that black keys are not as evenly spaced as white keys - they have gaps. Can you come up with a solution to this? Hint: create a special entry in your array where the gaps are, and use that to recognise the gaps. Hint: there is a String method available called "equals" that allows you to compare the string with another string. It will return true if the two strings are the same. Summary During this topic we have built another application completely, using the techniques you have learned previously and a few new techniques. You have used FOUR new constructs/concepts that you will use over and over while programming: State variables to make decisions based on the state of an application or object at a particular time; Using parameters in constructor methods to set up initial values of the object including the image used, and any other information needed that differs between objects; While loops that repeat a section of code over and over, until a given condition is false; and the concept of array variables that store a number of related values in one array variable. The workshop activities are to be included in your portfolio under a separate folder Module 7. ISY00245 Module 7 - Page 13
15 Workshop activities Activity R7-1 *** Portfolio Activity *** 1. Declare and initialise a String array called names with the names of three of your classmates, or if you are an Online student, three of the names from one of the lectures. 2. Write the code that will play a sound "ouch.wav" 20 times, using a while loop. 3. Consider the following code: int x = 3; int i = 0; while (i < 3) x = x + 1; i = i + 1; What is the value of x after this code has executed? Place your answers to this exercise in your portfolio document under the heading "Activity R7-1". **** Activity R7-2 Portfolio Activity *** Note: all text answers for the remaining exercises in this module should go into your porfolio document under the heading of the particular Activity. Each individual program, when it is completed, should be saved as a gfar with the name of the activity (eg: activityr7-2.gfar) in a Module 7 folder in your portfolio folder. 1. Open the scenario called bubbles. You will see that the world is empty. Place some Bubble objects into the world, using the default constructor. Remember you can also do this by shift-clicking into the world. What do you observe? 2. What is the initial size of a new bubble? What is its initial colour? What its initial direction of movement? 3. In the world subclass, Space, create a new private method called setup(). Call this method from the constructor. In this method, create a new bubble, using the default constructure, and place it in the centre of the world. Compile, then click Reset a few times to test. 4. Change your setup() method so that it creates 21 bubbles. Use a while loop. All bubbles will be placed in the centre of the world. Run your scenario to test. 5. Place the 21 bubbles at random locations in the world. 6. Save your program in the Portfolio/Module7/ folder as ActivityR7-2.gfar. ISY00245 Module 7 - Page 14
16 **** Activity R7-3 Portfolio Activity *** Note: all text answers for the remaining exercises in this module should go into your porfolio document under the heading of the particular Activity. Each individual program, when it is completed, should be saved as a gfar with the name of the activity (eg: activityr7-3.gfar) in a Module 7 folder in your portfolio folder. Using your program from Activity R7-2, alter your code to place the bubbles on a diagonal, with x and y distances of 30. The first bubble will be at (0,0), the next at (30,30) and so on. The last one will be at (600,600) for 21 bubbles. Use your loop counter variable to achieve this. Save your program in the Portfolio/Module7 folder as ActivityR7-3.gfar. **** Activity R7-4 Portfolio Activity *** Note: all text answers for the remaining exercises in this module should go into your porfolio document under the heading of the particular Activity. Each individual program, when it is completed, should be saved as a gfar with the name of the activity (eg: activityr7-4.gfar) in a Module 7 folder in your portfolio folder. Using your program from Activity R7-3, alter your code to place the bubbles on a diagonal, so that they go from the top left corner of the world to the bottom right corner. The last bubble should be at 900,600. Save your program in the Portfolio/Module7 folder as ActivityR7-4.gfar. **** Activity R7-5 Portfolio Activity *** Note: all text answers for the remaining exercises in this module should go into your porfolio document under the heading of the particular Activity. Each individual program, when it is completed, should be saved as a gfar with the name of the activity (eg: activityr7-5.gfar) in a Module 7 folder in your portfolio folder. Using your program from Activity R7-4, alter your code to add a second while loop to your setup() method that places some more bubbles. This loop should place 10 bubbles in a horizontal line, starting at x = 100, y = 11, with x increading by 40 every time and y being constant. The size of the bubble should also increase, starting with 10 for the first bubble, then 20, then 30 etc. Use the second Bubble constructor for this (the one with one parameter).. Save your program in the Portfolio/Module7 folder as ActivityR7-5.gfar. ISY00245 Module 7 - Page 15
17 **** Activity R7-6 Portfolio Activity *** Note: all text answers for the remaining exercises in this module should go into your porfolio document under the heading of the particular Activity. Each individual program, when it is completed, should be saved as a gfar with the name of the activity (eg: activityr7-6.gfar) in a Module 7 folder in your portfolio folder. Remove the existing loops from your setup() method. Write a new while loop that does the following: 1. creates 18 bubbles 2. places the bubbles in the centre of the world, with sizes starting from 190, and decreasing by the last bubble should have size 10. Make sure to create the largest first and the smallest last, so that you have bubbles of sizes 190, 180, 170 etc all lying on top of each other. Use the third constructor of Bubble - the one with two parameters. It also lets you specify the initial direction. Set the direction as follows: the first bubble has direction 0, the next 20, the next 40 etc. Test Save your program in the Portfolio/Module7 folder as ActivityR7-6.gfar. ISY00245 Module 7 - Page 16
Instructor. Software
Instructor Dr. Desmond Yau-chat TSOI (Simply call me Desmond ;) ) Engineering Workshop for HKUST Summer Camp 2017 Topic: Make an On Screen Piano to Play Your Favorite Music 30 June 2017 (Friday), Rm 4213
More informationCreating Java Programs with Greenfoot
Creating Java Programs with Greenfoot Using Loops, Variables, and Strings 1 Copyright 2012, Oracle and/or its affiliates. All rights Overview This lesson covers the following topics: Create a while loop
More informationCSE 113 A. Announcements - Lab
CSE 113 A February 21-25, 2011 Announcements - Lab Lab 1, 2, 3, 4; Practice Assignment 1, 2, 3, 4 grades are available in Web-CAT look under Results -> Past Results and if looking for Lab 1, make sure
More informationThe first program: Little Crab
Chapter 2 The first program: Little Crab topics: concepts: writing code: movement, turning, reacting to the screen edges source code, method call, parameter, sequence, if-statement In the previous chapter,
More informationImproving the crab: more sophisticated programming
Chapter 3 Improving the crab: more sophisticated programming topics: concepts: random behavior, keyboard control, sound dot notation, random numbers, defining methods, comments In the previous chapter,
More informationImproving the Crab more sophisticated programming
CHAPTER 3 Improving the Crab more sophisticated programming topics: concepts: random behavior, keyboard control, sound dot notation, random numbers, defining methods, comments In the previous chapter,
More informationCreating Java Programs with Greenfoot
Creating Java Programs with Greenfoot Using Randomization and Understanding Dot Notation and Constructors 1 Copyright 2012, Oracle and/or its affiliates. All rights Overview This lesson covers the following
More informationTopics. Java arrays. Definition. Data Structures and Information Systems Part 1: Data Structures. Lecture 3: Arrays (1)
Topics Data Structures and Information Systems Part 1: Data Structures Michele Zito Lecture 3: Arrays (1) Data structure definition: arrays. Java arrays creation access Primitive types and reference types
More informationMarking Period 1. Marking Period 2
DEPARTMENT: Mathematics COURSE: Programming Through Games & Simulation Week Marking Period 1 1 Intro to Greenfoot 2 Little Crabs 3 Little Crabs 4 Fishing the Crab Game 5 Fishing the Crab Game 6 Fat Cat
More informationCMSC 341 Lecture 7 Lists
CMSC 341 Lecture 7 Lists Today s Topics Linked Lists vs Arrays Nodes Using Linked Lists Supporting Actors (member variables) Overview Creation Traversal Deletion UMBC CMSC 341 Lists 2 Linked Lists vs Arrays
More informationCreating Java Programs with Greenfoot
Creating Java Programs with Greenfoot Defining Methods 1 Copyright 2012, Oracle and/or its affiliates. All rights Overview This lesson covers the following topics: Describe effective placement of methods
More informationHOUR 4 Understanding Events
HOUR 4 Understanding Events It s fairly easy to produce an attractive interface for an application using Visual Basic.NET s integrated design tools. You can create beautiful forms that have buttons to
More informationCS Programming Exercise:
CS Programming Exercise: An Introduction to Java and the ObjectDraw Library Objective: To demonstrate the use of objectdraw graphics primitives and Java programming tools This lab will introduce you to
More informationSession 8 Finishing Touches to the Air Raid Game
Session 8 Finishing Touches to the Air Raid Game Authored by Brian Cullen (bcullen@rossettschool.co.uk/@mrbcullen) (c) Copyright 2011 Computing At School. This work is licensed under the Creative Commons
More informationChaos Culture. MIDI Modulators / Multiclip Note preview 1.6. Edited by Jason Cowling
Chaos Culture Introduction... 2 Important stuff... 2 Setup... 3 Editing clips... 4 Using the editor... 5 Modulators... 8 Settings... 9 Work$ow settings... 10 Performance... 13 Future updates... 13 1.8.99
More informationGetting to know Greenfoot
CHAPTER 1 Getting to know Greenfoot topics: concepts: the Greenfoot interface, interacting with objects, invoking methods, running a scenario object, class, method call, parameter, return value This book
More informationConstants are named in ALL_CAPS, using upper case letters and underscores in their names.
Naming conventions in Java The method signature Invoking methods All class names are capitalized Variable names and method names start with a lower case letter, but every word in the name after the first
More informationChaos Culture. Multiclip Editor / Multiclip Note preview 1.5. Edited by Jason Cowling
Chaos Culture Introduction... 2 Important stuff... 2 Setup... 3 Editing clips... 4 Using the editor... 5 Settings... 9 Workflow settings... 10 Performance... 13 Future updates... 13 Editor 1.6.61 / Note
More information[ the academy_of_code] Senior Beginners
[ the academy_of_code] Senior Beginners 1 Drawing Circles First step open Processing Open Processing by clicking on the Processing icon (that s the white P on the blue background your teacher will tell
More informationExcel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller
Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Table of Contents Introduction!... 1 Part 1: Entering Data!... 2 1.a: Typing!... 2 1.b: Editing
More informationAssignment 4: Dodo gets smarter
Assignment 4: Dodo gets smarter Algorithmic Thinking and Structured Programming (in Greenfoot) 2017 Renske Smetsers-Weeda & Sjaak Smetsers 1 Contents Introduction 1 Learning objectives 1 Instructions 1
More informationGreenfoot! Introducing Java With Games And Simulations. Workshop material. Wombats. Object Orientation. Asteroids, Ants and other creatures.
Greenfoot! Introducing Java With Games And Simulations Michael Kölling University of Kent Birmingham, June 2009 Workshop material Download and install Greenfoot: www.greenfoot.org Wombats. Download the
More informationInteractive Tourist Map
Adobe Edge Animate Tutorial Mouse Events Interactive Tourist Map Lesson 1 Set up your project This lesson aims to teach you how to: Import images Set up the stage Place and size images Draw shapes Make
More informationAssignment 4. Aggregate Objects, Command-Line Arguments, ArrayLists. COMP-202B, Winter 2011, All Sections. Due: Tuesday, March 22, 2011 (13:00)
Assignment 4 Aggregate Objects, Command-Line Arguments, ArrayLists COMP-202B, Winter 2011, All Sections Due: Tuesday, March 22, 2011 (13:00) You MUST do this assignment individually and, unless otherwise
More informationCSE331 Autumn 2011 Midterm Examination October 28, 2011
CSE331 Autumn 2011 Midterm Examination October 28, 2011 50 minutes; 75 points total. Open note, open book, closed neighbor, closed anything electronic (computers, webenabled phones, etc.) An easier-to-read
More informationAnimation Workshop. Support Files. Advanced CODING CHALLENGE - ADVANCED
Animation Workshop Support Files Greenfoot Application: Greenfoot.org/download Greenfoot Reference: Greenfoot.org/files/javadoc/Greenfoot/package-summary Template: Scholastic.com/samsungacademy/resources/animation.zip
More informationRepetition Structures
Repetition Structures Chapter 5 Fall 2016, CSUS Introduction to Repetition Structures Chapter 5.1 1 Introduction to Repetition Structures A repetition structure causes a statement or set of statements
More informationCondition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.
Repetition Structures Introduction to Repetition Structures Chapter 5 Spring 2016, CSUS Chapter 5.1 Introduction to Repetition Structures The Problems with Duplicate Code A repetition structure causes
More informationChapter 1: First Steps 1
Chapter 1: The first steps Topic: Programming Page: 1 Chapter 1: First Steps 1 Start Eclipse. Import the Eclipse project scenarios-chapter-1. Go to the src/scenario01 subfolder. The scenario includes a
More informationVBA Excel 2013/2016. VBA Visual Basic for Applications. Learner Guide
VBA Visual Basic for Applications Learner Guide 1 Table of Contents SECTION 1 WORKING WITH MACROS...5 WORKING WITH MACROS...6 About Excel macros...6 Opening Excel (using Windows 7 or 10)...6 Recognizing
More informationCollections, Maps and Generics
Collections API Collections, Maps and Generics You've already used ArrayList for exercises from the previous semester, but ArrayList is just one part of much larger Collections API that Java provides.
More informationCS 506, Sect 002 Homework 5 Dr. David Nassimi Foundations of CS Due: Week 11, Mon. Apr. 7 Spring 2014
CS 506, Sect 002 Homework 5 Dr. David Nassimi Foundations of CS Due: Week 11, Mon. Apr. 7 Spring 2014 Study: Chapter 4 Analysis of Algorithms, Recursive Algorithms, and Recurrence Equations 1. Prove the
More informationDefinition: A data structure is a way of organizing data in a computer so that it can be used efficiently.
The Science of Computing I Lesson 4: Introduction to Data Structures Living with Cyber Pillar: Data Structures The need for data structures The algorithms we design to solve problems rarely do so without
More informationLesson 6A Loops. By John B. Owen All rights reserved 2011, revised 2014
Lesson 6A Loops By John B. Owen All rights reserved 2011, revised 2014 Topic List Objectives Loop structure 4 parts Three loop styles Example of a while loop Example of a do while loop Comparison while
More informationD - Tic Tac Toe. Let's use our 9 sparkles to build a tic tac toe game! 2017 courses.techcamp.org.uk/ Page 1 of 9
D - Tic Tac Toe Let's use our 9 sparkles to build a tic tac toe game! 2017 courses.techcamp.org.uk/ Page 1 of 9 INTRODUCTION Let's use our 9 sparkles to build a tic tac toe game! Step 1 Assemble the Robot
More informationAnjuli Kannan. Google Earth Driving Simulators (3:00-7:00)
Google Earth Driving Simulators (3:00-7:00) An example of what you can do by learning the GoogleEarth API, once you know how to write code Google has published such an API so that people can make programs
More informationA PROGRAM IS A SEQUENCE of instructions that a computer can execute to
A PROGRAM IS A SEQUENCE of instructions that a computer can execute to perform some task. A simple enough idea, but for the computer to make any use of the instructions, they must be written in a form
More informationTutorial. Creating activities in Expert mode
Tutorial Creating activities in Expert mode 1 Index 1. Making a simple one answer activity 3 2. Making a sequencing activity... 11 3. Making a sorting activity 15 4. Some additional tips and things to
More informationTopic 7: Algebraic Data Types
Topic 7: Algebraic Data Types 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 5.5, 5.7, 5.8, 5.10, 5.11, 5.12, 5.14 14.4, 14.5, 14.6 14.9, 14.11,
More informationComputer Science Lab Exercise 1
1 of 10 Computer Science 127 - Lab Exercise 1 Introduction to Excel User-Defined Functions (pdf) During this lab you will experiment with creating Excel user-defined functions (UDFs). Background We use
More informationAbout Technocamps. We go around schools and show you lots of interesting stuff! We also do things we call bootcamps during holidays!
Greenfoot About Technocamps We go around schools and show you lots of interesting stuff! We also do things we call bootcamps during holidays! Pre-day Questionnaires This is a Computer What do computers
More informationCS Problem Solving and Object-Oriented Programming
CS 101 - Problem Solving and Object-Oriented Programming Lab 5 - Draw a Penguin Due: October 28/29 Pre-lab Preparation Before coming to lab, you are expected to have: Read Bruce chapters 1-3 Introduction
More informationIT82: Multimedia Macromedia Director Practical 1
IT82: Multimedia Macromedia Director Practical 1 Over the course of these labs, you will be introduced Macromedia s Director multimedia authoring tool. This is the de facto standard for time-based multimedia
More information+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.
+ Inheritance + Inheritance Classes that we design in Java can be used to model some concept in our program. For example: Pokemon a = new Pokemon(); Pokemon b = new Pokemon() Sometimes we need to create
More informationChapter 1: First Steps to Greenfoot 1
Chapter 1: The first steps Topic: Programming Page: 1 Chapter 1: First Steps to Greenfoot 1 Start Greenfoot. (If you open Greenfoot for the first time, a dialog box that asks what you want. Click on choose
More informationThe Thomas Hardye School Summer Preparation Task Computer Science AS
The Thomas Hardye School Summer Preparation Task Computer Science AS Purpose of task: You should download and install the Python IDLE on your home computer to enable you to practice writing code using
More informationThe Thomas Hardye School Summer Preparation Task Computer Science A Level
The Thomas Hardye School Summer Preparation Task Computer Science A Level Purpose of task: You should download and install the Python IDLE on your home computer to enable you to practice writing code using
More informationComputer Games Development Spring Practical 3 GameCore, Transforms & Collision Detection
In this practical we are going to look at the GameCore class in some detail and then move on to examine the use of transforms, collision detection and tile maps. Combined with the material concerning sounds
More informationFor many people, learning any new computer software can be an anxietyproducing
1 Getting to Know Stata 12 For many people, learning any new computer software can be an anxietyproducing task. When that computer program involves statistics, the stress level generally increases exponentially.
More informationCSE 331 Final Exam 12/9/13
Name There are 10 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes, closed
More informationEducational Fusion. Implementing a Production Quality User Interface With JFC
Educational Fusion Implementing a Production Quality User Interface With JFC Kevin Kennedy Prof. Seth Teller 6.199 May 1999 Abstract Educational Fusion is a online algorithmic teaching program implemented
More informationCreating Java Programs with Greenfoot
Creating Java Programs with Greenfoot Working with Source Code and Documentation 1 Copyright 2012, Oracle and/or its affiliates. All rights Objectives This lesson covers the following topics: Demonstrate
More informationInitial Coding Guidelines
Initial Coding Guidelines ITK 168 (Lim) This handout specifies coding guidelines for programs in ITK 168. You are expected to follow these guidelines precisely for all lecture programs, and for lab programs.
More information1 Getting started with Processing
cis3.5, spring 2009, lab II.1 / prof sklar. 1 Getting started with Processing Processing is a sketch programming tool designed for use by non-technical people (e.g., artists, designers, musicians). For
More informationCOMP : Practical 9 ActionScript: Text and Input
COMP126-2006: Practical 9 ActionScript: Text and Input This practical exercise includes two separate parts. The first is about text ; looking at the different kinds of text field that Flash supports: static,
More informationLoad your files from the end of Lab A, since these will be your starting point.
Coursework Lab B It is extremely important that you finish lab A first, otherwise this lab session will probably not make sense to you. Lab B gives you a lot of the background and basics. The aim of the
More informationAgenda CS121/IS223. Reminder. Object Declaration, Creation, Assignment. What is Going On? Variables in Java
CS121/IS223 Object Reference Variables Dr Olly Gotel ogotel@pace.edu http://csis.pace.edu/~ogotel Having problems? -- Come see me or call me in my office hours -- Use the CSIS programming tutors Agenda
More informationSession 4 Starting the Air Raid Game
Session 4 Starting the Air Raid Game Authored by Brian Cullen (bcullen@rossettschool.co.uk/@mrbcullen) (c) Copyright 2011 Computing At School. This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike
More informationC/C++ Programming Lecture 18 Name:
. The following is the textbook's code for a linear search on an unsorted array. //***************************************************************** // The searchlist function performs a linear search
More informationCSE 142 Su 02 Homework 4
CSE 142 - Su 02 Homework 4 Assigned: Wednesday, July 17 Due: Wednesday, July 24, BEFORE MIDNIGHT ** General Comments about the Homework ** All homework is turned in electronically. Go to the class web
More informationJava Foundations. 7-2 Instantiating Objects. Copyright 2015, Oracle and/or its affiliates. All rights reserved.
Java Foundations 7-2 Copyright 2015, Oracle and/or its affiliates. All rights reserved. Objectives This lesson covers the following objectives: Understand the memory consequences of instantiating objects
More informationCS 134 Programming Exercise 3:
CS 134 Programming Exercise 3: Repulsive Behavior Objective: To gain experience implementing classes and methods. Note that you must bring a program design to lab this week! The Scenario. For this lab,
More informationAdobe Flash CS3 Reference Flash CS3 Application Window
Adobe Flash CS3 Reference Flash CS3 Application Window When you load up Flash CS3 and choose to create a new Flash document, the application window should look something like the screenshot below. Layers
More informationIntroduction to Unreal Engine Blueprints for Beginners. By Chaven R Yenketswamy
Introduction to Unreal Engine Blueprints for Beginners By Chaven R Yenketswamy Introduction My first two tutorials covered creating and painting 3D objects for inclusion in your Unreal Project. In this
More informationWe will start our journey into Processing with creating static images using commands available in Processing:
Processing Notes Chapter 1: Starting Out We will start our journey into Processing with creating static images using commands available in Processing: rect( ) line ( ) ellipse() triangle() NOTE: to find
More informationMYOB Exo PC Clock. User Guide
MYOB Exo PC Clock User Guide 2018.01 Table of Contents Introduction to MYOB Exo PC Clock... 1 Installation & Setup... 2 Server-based... 2 Standalone... 3 Using Exo PC Clock... 4 Clocking Times... 5 Updating
More informationIf you don t, it will return the same thing as == But this may not be what you want... Several different kinds of equality to consider:
CS61B Summer 2006 Instructor: Erin Korber Lecture 5, 3 July Reading for tomorrow: Chs. 7 and 8 1 Comparing Objects Every class has an equals method, whether you write one or not. If you don t, it will
More informationName: Magpie Chatbot Lab: Student Guide. Introduction
Magpie Chatbot Lab: Student Guide Introduction From Eliza in the 1960s to Siri and Watson today, the idea of talking to computers in natural language has fascinated people. More and more, computer programs
More informationTesting is a very big and important topic when it comes to software development. Testing has a number of aspects that need to be considered.
Testing Testing is a very big and important topic when it comes to software development. Testing has a number of aspects that need to be considered. System stability is the system going to crash or not?
More informationTitle and Modify Page Properties
Dreamweaver After cropping out all of the pieces from Photoshop we are ready to begin putting the pieces back together in Dreamweaver. If we were to layout all of the pieces on a table we would have graphics
More informationSIMPLE TEXT LAYOUT FOR COREL DRAW. When you start Corel Draw, you will see the following welcome screen.
SIMPLE TEXT LAYOUT FOR COREL DRAW When you start Corel Draw, you will see the following welcome screen. A. Start a new job by left clicking New Graphic. B. Place your mouse cursor over the page width box.
More informationCS121/IS223. Object Reference Variables. Dr Olly Gotel
CS121/IS223 Object Reference Variables Dr Olly Gotel ogotel@pace.edu http://csis.pace.edu/~ogotel Having problems? -- Come see me or call me in my office hours -- Use the CSIS programming tutors CS121/IS223
More information5/31/2006. Last Time. Announcements. Today. Variable Scope. Variable Lifetime. Variable Scope - Cont. The File class. Assn 3 due this evening.
Last Time Announcements The File class. Back to methods Passing parameters by value and by reference. Review class attributes. An exercise to review File I/O, look at passing by reference and the use of
More information+ Abstract Data Types
Linked Lists Abstract Data Types An Abstract Data Type (ADT) is: a set of values a set of operations Sounds familiar, right? I gave a similar definition for a data structure. Abstract Data Types Abstract
More informationIntroduction to Programming using C++
Introduction to Programming using C++ Lecture One: Getting Started Carl Gwilliam gwilliam@hep.ph.liv.ac.uk http://hep.ph.liv.ac.uk/~gwilliam/cppcourse Course Prerequisites What you should already know
More informationNews and information! Review: Java Programs! Feedback after Lecture 2! Dead-lines for the first two lab assignment have been posted.!
True object-oriented programming: Dynamic Objects Reference Variables D0010E Object-Oriented Programming and Design Lecture 3 Static Object-Oriented Programming UML" knows-about Eckel: 30-31, 41-46, 107-111,
More informationProgramming Project 1
Programming Project 1 Handout 6 CSCI 134: Fall, 2016 Guidelines A programming project is a laboratory that you complete on your own, without the help of others. It is a form of take-home exam. You may
More informationExcel Basics: Working with Spreadsheets
Excel Basics: Working with Spreadsheets E 890 / 1 Unravel the Mysteries of Cells, Rows, Ranges, Formulas and More Spreadsheets are all about numbers: they help us keep track of figures and make calculations.
More informationMacromedia Director Tutorial 4
Macromedia Director Tutorial 4 Further Lingo Contents Introduction...1 Play and Play done...2 Controlling QuickTime Movies...3 Controlling Playback...3 Introducing the if, then, else script...6 PuppetSprites
More information= 3 + (5*4) + (1/2)*(4/2)^2.
Physics 100 Lab 1: Use of a Spreadsheet to Analyze Data by Kenneth Hahn and Michael Goggin In this lab you will learn how to enter data into a spreadsheet and to manipulate the data in meaningful ways.
More informationTutorial 3: Constructive Editing (2D-CAD)
(2D-CAD) The editing done up to now is not much different from the normal drawing board techniques. This section deals with commands to copy items we have already drawn, to move them and to make multiple
More informationCS112 Lecture: Loops
CS112 Lecture: Loops Objectives: Last revised 3/11/08 1. To introduce some while loop patterns 2. To introduce and motivate the java do.. while loop 3. To review the general form of the java for loop.
More informationAnimations involving numbers
136 Chapter 8 Animations involving numbers 8.1 Model and view The examples of Chapter 6 all compute the next picture in the animation from the previous picture. This turns out to be a rather restrictive
More informationWithin the spreadsheet, columns are labeled with letters and rows are labeled with numbers.
Excel Exercise 1: Goals: 1. Become familiar with Guidelines for spans and proportions of common spanning members (Chapter 1). 2. Become familiar with basic commands in Excel for performing simple tasks
More informationCurriculum Map Grade(s): Subject: AP Computer Science
Curriculum Map Grade(s): 11-12 Subject: AP Computer Science (Semester 1 - Weeks 1-18) Unit / Weeks Content Skills Assessments Standards Lesson 1 - Background Chapter 1 of Textbook (Weeks 1-3) - 1.1 History
More informationCSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch
CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch Purpose: We will take a look at programming this week using a language called Scratch. Scratch is a programming language that was developed
More informationCS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM
CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM Objectives The objectives of this assignment are: to get your first experience with Java to become familiar with Eclipse Java
More informationIntroduction to Programming in C Department of Computer Science and Engineering. Lecture No. #34. Function with pointer Argument
Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #34 Function with pointer Argument (Refer Slide Time: 00:05) So, here is the stuff that we have seen about pointers.
More informationSelect the ONE best answer to the question from the choices provided.
FINAL EXAM Introduction to Computer Science UAlbany, Coll. Comp. Info ICSI 201 Spring 2013 Questions explained for post-exam review and future session studying. Closed book/notes with 1 paper sheet of
More informationC++ Style Guide. 1.0 General. 2.0 Visual Layout. 3.0 Indentation and Whitespace
C++ Style Guide 1.0 General The purpose of the style guide is not to restrict your programming, but rather to establish a consistent format for your programs. This will help you debug and maintain your
More information5. PLEASE TAKE HOME the question bundle, but turn in 2 paper sheets: The scantron AND the paper where you wrote your programming question solution!
FINAL EXAM Introduction to Computer Science UA-CCI- ICSI 201--Fall13 This is a closed book and note examination, except for one 8 1/2 x 11 inch paper sheet of notes, both sides. There is no interpersonal
More informationAbout this exam review
Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review
More informationFrontPage 98 Quick Guide. Copyright 2000 Peter Pappas. edteck press All rights reserved.
Master web design skills with Microsoft FrontPage 98. This step-by-step guide uses over 40 full color close-up screen shots to clearly explain the fast and easy way to design a web site. Use edteck s QuickGuide
More informationIn the first class, you'll learn how to create a simple single-view app, following a 3-step process:
Class 1 In the first class, you'll learn how to create a simple single-view app, following a 3-step process: 1. Design the app's user interface (UI) in Xcode's storyboard. 2. Open the assistant editor,
More informationNote: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.
Com S 227 Fall 2017 Miniassignment 1 50 points Due Date: Monday, October 16, 11:59 pm (midnight) Late deadline (25% penalty): Tuesday, October 17, 11:59 pm General information This assignment is to be
More informationWord: Print Address Labels Using Mail Merge
Word: Print Address Labels Using Mail Merge No Typing! The Quick and Easy Way to Print Sheets of Address Labels Here at PC Knowledge for Seniors we re often asked how to print sticky address labels in
More information1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall 2002 Problem Set 3 Due: Day 11. Problem 1. Finding the Median (15%)
1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall 2002 Problem Set 3 Due: Day 11 Problem 1. Finding the Median (15%) Write a method that takes in an integer array and returns an
More informationMicrosoft Excel 2010 Handout
Microsoft Excel 2010 Handout Excel is an electronic spreadsheet program you can use to enter and organize data, and perform a wide variety of number crunching tasks. Excel helps you organize and track
More informationLesson 4: Introduction to the Excel Spreadsheet 121
Lesson 4: Introduction to the Excel Spreadsheet 121 In the Window options section, put a check mark in the box next to Formulas, and click OK This will display all the formulas in your spreadsheet. Excel
More information