Assignment 1: Meet Dodo

Size: px
Start display at page:

Download "Assignment 1: Meet Dodo"

Transcription

1 Assignment 1: Meet Dodo Algorithmic Thinking and Structured Programming (in Greenfoot) 2017 Renske Smetsers-Weeda & Sjaak Smetsers 1 Contents Introduction 1 Learning objectives 2 Instructions 2 Theory Dodo s world Objects Algorithms Methods Classes and inheritance The state of an object Parameters and results Signatures Reading flowchart and code Java Documentation Modifying, compiling and testing programs Naming conventions Errors Printing to the console Challenges Getting started with Greenfoot Creating objects Exploring the accessor method Exploring the mutator method Inheritance States Calling Accessor Methods Using Parameters Licensed under the Creative Commons Attribution 4.0 license:

2 1.9 Reading a flowchart and its corresponding code Adding a new method turn180() Error messages Printing text to the console Printing variables to the console Printing coordinates to the console Reflection 24 Diagnostic Test 25 Saving and Handing in 27 Algorithmic thinking and structured programming (in Greenfoot) 2

3 Introduction In this series of assignments, Algorithmic Thinking and Structured Programming (in Greenfoot), you will learn Algorithmic Thinking and the basics of Object Oriented programming... and (hopefully will) be having fun in the process. After completion you will be able to program in Java, in addition to being able to use Greenfoot and Java libraries. With these skills, you will be able to quickly learn other (Object Oriented) programming languages. You will also learn how to use and adapt existing code where necessary. Re-use of existing code is one of Java s strengths, because it allows you to make more complex programs in less time. Programming You will program in the Java language. For the assignments we will use the Greenfoot programming environment. This is an environment that allows you to write Java code without first having to learn (the theory of) Java in full-depth. In such a manner you can gradually learn Java while you re actually using it to make stuff. You will learn the basic building blocks that are used for algorithms and programs. Setting Figure 1: Mimi the Dodo This is Mimi, our Dodo. A Dodo (a bird which is now extinct) was never very intelligent. At first you will teach the Dodo simple tasks, like walking and turning. Throughout the course, you will teach the Dodo to complete more complex tasks, such as independently walking through any given maze. One of the final tasks is a competition with your classmates: who can make the smartest Dodo? Computational Thinking Computational thinking involves solving problems, designing systems, and understanding human behavior. It s not about trying to get humans to think like computers; it is a way humans solve problems. Thinking like a computer scientist means more than being able to program a computer. It requires problem solving. If you want to learn how to play chess, you have to know the rules. These rules tell you what you can and what you can t do. But if you want to play chess well and enjoy playing the game, then merely knowing the rules is not enough. You also have to learn what a good move is. On internet you can find numerous Java tutorials and manuals. Those teach you the rules, but little about how to write a program well. In this course you will learn how to systematically deal with a programming task. You will learn to analyze problems and develop an appropriate solution in a structured and organized manner. The goal is to teach you to program well, and let you enjoy doing so. Goals The course is divided into several assignments. This assignment s goals are: To learn how to make code modifications in a structured manner; Become acquainted with the Greenfoot environment. Algorithmic thinking and structured programming (in Greenfoot) 1

4 Learning objectives After completing this assignment, you will be able to: find your way around the Greenfoot programming environment; invoke methods and analyze their effect; in your own words, describe the difference between a mutator method and an accessor method; identify and list (inherited) methods of a class; use a class diagram to identify classes and subclasses; identify properties of an object s state; describe what the types int, String, void, and boolean are; given a signature, identify a method s result type and parameter(type)s; describe the relationship between an algorithm, a flowchart and program code; add JavaDoc comments to code; incrementally make code modifications and then compile and test; recognize and interpret (syntax) errors; print to a console. Instructions For this assignment you will need: Greenfoot: Instructions for installing and opening the Greenfoot environment are given further on; scenario DodoScenario1 : to be downloaded from the course website 2. Throughout the assignment you will also need to answer some questions. The following must be handed in: All flowcharts: use pencil and paper, or go to Your code: the file MyDodo. jav contains all your code and must be handed in; The reflection sheet: complete and hand it in. You must discuss all other answers with a programming partner. Jot down a short answer on (the assignment) paper. There are three types of challenges: Recommended. Students who need more practice or with limited programming experience should complete all of these. Mandatory. Everyone must complete these. Excelling. More inquisitive tasks, designed for students who completed 2 star tasks and are ready for a bigger challenge. Students who skip 1-star challenges should complete all 3-star challenges. 2 Algorithmic thinking and structured programming (in Greenfoot) 2

5 Theory Theory 1.1: Dodo s world Mimi belongs to the Dodo family. Here she is, facing East. Mimi lives in a (grid)world that is made-up of 12 by 12 squares. Her world is bounded, she can t get out. Her sole goal in life is to lay and hatch eggs. The picture shows the world s coordinate system. Figure 2: Mimi s world Mimi is a very well-behaved Dodo. She does exactly what she is told to do, and she always gives honest answers to your questions (she never lies). By calling methods, you can tell her to do something or ask her questions. You can let Mimi do things, such as: move hatchegg jump move one square ahead hatch an egg jump several squares ahead You can also ask Mimi a question, such as: canmove getnrofeggshatched Can you take a step forward? How many eggs have you hatched? Theory 1.2: Objects A world consists of objects (also known as class instances, or simply instances). By selecting new MyDodo ( ) you can create a new object of MyDodo. The world below shows one MyDodo object and three Egg objects. Algorithmic thinking and structured programming (in Greenfoot) 3

6 Figure 3: Scenario with one MyDodo object and three Egg objects In our assignments we have one lead actress, a MyDodo object. She is an instance of MyDodo. We will call her Mimi. Theory 1.3: Algorithms An algorithm is a very precisely defined set of instructions. Program code is an algorithm written specifically for a computer. It tells the computer exactly, step by step, what it should do. If a set of instructions has been described precisely enough, someone else should be able to follow the steps precisely as you meant it. For the same problem (initial situation) the instructions will lead to exactly the same outcome (final situation). It is similar to a recipe. The difference with a recipe is that an algorithm is more precise. For example, a recipe might say stir until smooth. However, each time you (or someone else) makes that dessert it may end up differently, one time being a bit smoother than the next. In an algorithm, it must be precisely clear what each step exactly means. The result must be exactly the same every time. Theory 1.4: Methods There are two types of methods, mutator methods and accessor methods, each with an own purpose: Mutator methods These are commands which make an object do something. It changes the state of an object. You can recognize a mutator method by its result: void. For example: void move ( ) changes the state of Dodo by moving it one cell ahead. void setdirection ( int new_direction ) changes the direction in which an object is facing. Accessor methods These are questions that provide information about (the state of) an object. For example: int getnrofeggshatched ( ) which returns an int (an integer, or whole number) indicating how many eggs Mimi has hatched. boolean canmove ( ) which returns a boolean (either true or false), indicating whether Mimi can take a step forwards or not. Accessor methods only provide information about an object, they don t do anything with an object: the object s state remains unchanged (for example, Dodo doesn t also move to another position). Algorithmic thinking and structured programming (in Greenfoot) 4

7 Theory 1.5: Classes and inheritance Every object belongs to a class. As such, Mimi is an instance of the MyDodo class. In the class diagram you can see that MyDodo belongs to the Dodo family. In Greenfoot, the class diagram is shown on the right-hand side of the screen. Have a look at figure 4. The arrow in the diagram shows an is-a relationship: MyDodo is-a Dodo. So, MyDodo belongs to the class Dodo. Figure 4: Class diagram MyDodo s methods Mimi is a MyDodo. Mimi has methods that you can call. By right-clicking on Mimi you can see what a MyDodo (and thus Mimi) can do. For example the move ( ) method. Dodo s methods But Mimi (our MyDodo) is capable of doing much more. There are things that all Dodos, in general, can do. Mimi is a Dodo, so of course she can also do all the the things that Dodo s can do too (and much more)! Right-click on Mimi (in the world). At the top of the list you see inherited from Dodo. If you click on that, then more methods will appear, such as layegg ( ). These are methods which belong to the class Dodo, things that all Dodos can do. Because MyDodo is a Dodo (see the class diagram in figure 4), Dodo inherits (or gets) all these Dodo methods too. So, because MyDodo is a subclass of Dodo, a MyDodo so can perform all Dodo methods (in addition to its own MyDodo methods). Inheritance The fact that MyDodo can borrow methods from her superclass Dodo is called inheritance. By using inheritance, a new class can be introduced as an extension of an existing class. An instance of a subclass can use all the methods from its superclass. In such a situation, the existing class is called the super class, and the extended class is called the subclass. Because MyDodo a subclass of Dodo, a MyDodo can execute methods from both the Dodo class as well as its own MyDodo class. Example of a class diagram Figure 5: Pet class diagram The class diagram in 5 shows that Cats and Dogs are subclasses of PetAnimal. Every PetAnimal can sleep () and eat (), thus so can Cats and Dogs. A Cat can meow (). This method is specific to only Cats. Algorithmic thinking and structured programming (in Greenfoot) 5

8 Theory 1.6: The state of an object You can place different objects in the world, such as a Dodo and an egg. You can also place several objects of the same class in the world at the same time. In the picture below you see three objects of the Egg class and one of the MyDodo class. Figure 6: A world with several objects All objects of the same class have the same methods, and thus have the same behavior. The three objects of Egg look identical and can do exactly the same things. Yet, they are different objects, or instances. Every object has its own state. States are made up of characteristics such as coordinates or appearance. To view the state of an object, right-click on the object and then choose Inspect. The following example shows the state of an Egg-object with coordinates (1,1) and one with coordinates (2,2). Figure 7: States of two Egg-objects Just like you re different from the person sitting next to you, even though you are both people. The mere fact that you are each sitting on different chairs or had something different for breakfast, makes you different. The same is true in the Greenfoot world. Every object has its own state. Theory 1.7: Parameters and results Results In section 1.4 we saw that accessor methods give information about an object s state (they answers questions). Such an answer is called the result of a method. For example, int getnrofeggshatched ( ) has an int (whole number) as its result. Parameters A method can also be given a certain value. This value, called a parameter, gives the method more information about a particular task. A method can have 0 or more parameters. Examples: void jump ( int distance ) has one parameter, distance, which tells the method how far it must jump. We can also tell that distance is a whole number, an int. By calling jump (3); Mimi will move forward 3 cells. By calling jump (5); Mimi will move forward 5 cells. The method jump needs this additional information in order to work. Otherwise, it would not know how many cells Mimi must move. void move ( ) has no parameters. void setdirection ( int new_direction ) has one parameter, an int new_direction which tells the method which direction to turn the object towards. Algorithmic thinking and structured programming (in Greenfoot) 6

9 Types Parameters and results have a type. The type indicates which sorts of values a parameter or result must have. Examples of different types are: Type Meaning Example int a whole number 2 boolean true or false true String text enclosed in quote marks I lost my pen. List list [1,2,3] A class can also be a type, such as a List of Eggs. It is not possible to call void jump ( int distance ) with no parameters because this method requires an int as a parameter. Theory 1.8: Signatures By looking at the signature of a method, you can see which parameters, parameter types and result types belong to the method. Method name: the method s name is indicated in front of the first parenthesis. In this example: jump. Parameter: the parameters that the method requires are indicated in between the parentheses ( and ). In this example: distance. Parameter type: the parameter s type (such as int, boolean, or String) is indicated in front of the parameter s name. In this example: int. Result type: the result s type (such as int, boolean, void) is indicated in front of the method s name. In this example the result type is void. This method doesn t return anything (it is a mutator method). Method s signature: together, all of the components above are called the signature. In this example: public void jump ( int distance ). (the meaning of public will be explained later) For the example above: Figure 8: Signature of a method Method name jump Parameter distance Parameter type int Result type void Method s signature public void jump ( int distance ) The types in the signature indicate which types of values a parameter or result must have. Algorithmic thinking and structured programming (in Greenfoot) 7

10 Theory 1.9: Reading flowchart and code An algorithm can be visually represented in a flowchart. This helps maintain overview, in turn making it easier to write, read and analyse code. As an example we will look at the algorithm of MyDodo s move ( ) method. We have already had a look at this method in challenge Figure 9: Flowchart and corresponding code Figure 10: Flowchart and corresponding code The flowchart explained Method name: move. The name can be found in the top-left corner. Initial and final situations are described in the note blocks in the top-right and bottom-right corners. You begin at Start at the top. Body: this is the part between the Start and End and describes what the method actually does. In this example: Follow the arrow to the diamond. The diamond means a decision (selection) is made, depending on the outcome of canmove? another path can be followed, namely: * If canmove? is False, then the arrow to the left is followed. Algorithmic thinking and structured programming (in Greenfoot) 8

11 * If canmove? is True, then the arrow to the right is followed. This behavior is consistent with that of an if.. then.. else statement in the code. In the case of a rectangle, a method is called. So, depending on which arrow has been followed the move or the turnright method will be executed. When the End is reached, then the move method is finished. The code explained Comment: the text in between /** and */ (shown in blue text in the Greenfoot editor) are comments. The compiler doesn t do anything with this. Programmers write comments in their code to help others understand their programs. The initial and final situations are described here. For comments in the code that fit on just one line, use //. Signature: this is public void move ( ). Access modifier: public. What this means and which other possibilities there are, will be explained later. Method name: move. Result type: void. What the method returns. This mutator method returns void which means it makes the object do something (as opposed to an accessor method which yields information about the object s state) (See theory 1.4). Body: this is the part between the first curly bracket { and its corresponding curly bracket } : what the method actually does. In this example you see a conditional expression: the if.. then.. else in the move ( ). It works like this: The condition is stated in between the parentheses ( and ). Firstly, the condition canmove is checked. * If the condition is true, then the code directly following the condition is executed. Thus, step ( ) is executed and Dodo takes a step. * If the condition is false, then the code after the else is executed. Thus, an error message with the text I m stuck is shown. Theory 1.10: Java Documentation Each method should have comments clarifying what the code does. In Java this is called JavaDoc ( Java Documentation ). Documenting your codes helps others (and yourself) understand and re-use code. Writing Java Documentation In Java there are some standard agreements on how to comment code (see figure 11 for an example): Each method has comments (globally) describing what the method does. Each method explains the initial and final situation. Comments are started by /** and ended by */. For comments not longer than one line can, you can use // followed by the indicates which parameters the method receives. Algorithmic thinking and structured programming (in Greenfoot) 9

12 @return indicates what the method returns. Figure 11: Comments belonging to the jump method Viewing Java Documentation To view your code s Java Documentation follow the following steps: 1. Open the code in the editor. 2. At the top-right of the screen, select Documentation instead of Source Code. (See figure 12) Figure 12: Selecting Java documentation instead of Source Code Theory 1.11: Modifying, compiling and testing programs To get Mimi to do more exciting things, you must write your own new methods. Obviously, you must first learn to read code before you can write code. Also, you should be able to describe which changes you want to make, after which you can actually make modifications to existing code. Modifications Always make changes incrementally. A typo can be introduced easily, whilst detecting it could be more troublesome. It is a good idea to compile, run and test every (small) change to the code so that you can quickly locate any mistakes. After each code change: 1. Compile: Press the Compile button on the top-left of the screen. Algorithmic thinking and structured programming (in Greenfoot) 10

13 Figure 13: The compile button 2. Execute: Call the method by right-clicking on Mimi and then choosing the method. Figure 14: Executing a method by right-clicking on Mimi in the world 3. Test: Check if the method does what you expect. Compare the initial and final situations. Work in a structured manner Make a habit of always following these steps after every code change. That way, if you make a mistake, you can quickly find what the problem is. If you make many changes in one go without testing in between, then debugging (detecting errors in your code) can become a time-consuming and very frustrating task! Theory 1.12: Naming conventions Naming conventions Methods and parameters have names. In Java, there are general conventions (or agreements) on how to choose a name. By following these conventions, your code becomes easier to read and understand for others. A method s name: is meaningful: it is consistent with what the method does Algorithmic thinking and structured programming (in Greenfoot) 11

14 is in the form of a command: it consists of one or more verbs consists of letters and numbers: it does not consist of spaces, commas, or other strange characters (with the exception of ) is written in lowercasecamel: starts with a lowercase letter, and each subsequent word starts with a capital letter for example: canmove A parameter s name: is meaningful: it is consistent with what the parameter means consists of one or more nouns consists of letters and numbers: it does not consist of spaces, commas, or other strange characters (with the exception of ) is written in lowercasecamel: starts with a lowercase letter, and each subsequent word starts with a capital letter for example: nrofeggs See for a complete overview of style and naming conventions. Theory 1.13: Errors Syntax errors If you type in something which the compiler does not understand, this is called a syntax error. Some common mistakes are: Mistake missing ; at the end of the line missing ( ) in the header missing { at beginning of body missing } at end of body missing } at end of class missing ( ) in method call typo (watch out for capital/lowercase) wrong parameter type used no parameter used wrong return type wrong type used Compiler error message ; expected ( expected ; expected illegal start of expression reached end of file when parsing not a statement cannot find symbol incompatible types method cannot be applied to given types incompatible types: unexpected return value cannot find symbol Logical errors Besides syntax errors, there are also other types of programming errors. The compiler will not complain, but the program does not do what is expected. This is called a logical error. Such an error can be very difficult to find, and can be very frustrating. Searching for such an error is called debugging. Because prevention is beter than curing, we will discuss good programming practices in the next assignment. By using a structured approach to programming you can significantly reduce the chance of these types of errors slipping into your code. Algorithmic thinking and structured programming (in Greenfoot) 12

15 Theory 1.14: Printing to the console When debugging, it can be useful to print values or statements to determine where errors are located. To make a console window appear with text you can use the following Java method: System. out. println ( String );. The following example shows the output in the console and its corresponding code. Figure 15: Printing in the console Depending on what needs to be printed, the println method is called with different arguments: Place text in between quotation marks and. To show the value of a variable (such as an integer, double or string), the quotation marks are not needed, just use the variable name. Combine texts and variables using +. Note: For more information about the Java println method, have a look at: 7/docs/api/java/io/PrintStream.html#println(java.lang.String). Algorithmic thinking and structured programming (in Greenfoot) 13

16 Challenges Challenge 1.1: Getting started with Greenfoot Starting Greenfoot We re going to play around with Mimi in the Greenfoot environment. To do this, you must download and install Greenfoot (if it has not already been done for you, you can download it at ) and open the given scenario. Download and install Greenfoot Version (if not already done): Choose a folder: Download: Go to Download the appropriate version for your operating system and follow the instructions for installation. Decide where you will save all your work. If you wish, you can use a USB-stick for this. Go to the course page and download the scenario files belonging to this assignment: Copy the given exe-file with initial scenario to the folder which you have chosen. Unpack the scenario at that location, just by clicking on the exe-file. Open the Greenfoot environment: Double click on the Greenfoot.exe file. The programming environment should start now. Open the scenario: Select Scenario in the main menu, and then Open. Navigate to the DodoScenario1 scenario (which you downloaden en unzipped) and chose Open. Rename the scenario: In the Greenfoot menu at the top of the screen, select Scenario and then Save As.... Check that the window opens in the folder where you want to save your work. Choose a file name containing your own name(s) and assignment number, for example: Asgmt1_John. You should see the following: Algorithmic thinking and structured programming (in Greenfoot) 14

17 Figure 16: What you see when you open the DodoScenario1 scenario Please read Theory 1.1: Dodo s world. Please read Theory 1.2: Objects. Challenge 1.2: Creating objects We re going to make the scenario as shown in figure 3: a) Right-click on MyDodo, on the far right-hand of the screen. b) Select new MyDodo ( ) to create a new MyDodo object. c) Drag the object, our MyDodo called Mimi, to a random position in the world. d) In the same manner, place three BlueEggs in the world. Tip: hold down the Shift button on your keyboard to place multiple blue eggs. Please read Theory 1.3: Algorithms. Please read Theory 1.4: Methods. Challenge 1.3: Exploring the accessor method By right-clicking on Mimi, you can see a list of all the things she can do (in other words, which methods you can call). By using some of those methods (called accessor methods) you can get Mimi to answer questions about herself. a) Drag Mimi into the middle of the world. Right-click on Mimi, and call the boolean canmove ( ) method. A dialogue box appears, as shown below. The method returns true. Algorithmic thinking and structured programming (in Greenfoot) 15

18 Figure 17: Dialogue box for canmove ( ) b) Can you move Mimi to another location so that boolean canmove ( ) returns a different result than true? c) What do you think boolean means? d) Besides returning a result, let s have a look at what such an accessor method does: i. Describe the current situation: Where is Mimi and what direction is she facing? Are there any eggs? ii. Call the method int getnrofeggshatched ( ). iii. Does calling this method change the situation in the world? e) What result did int getnrofeggshatched ( ) give? What does int mean? f) Can you create a situation in which the method int getnrofeggshatched ( ) returns the value 3? Tip: first place eggs in the world and then call hatchegg ( ). You have now seen that an accessor method returns information such as int or boolean, but shouldn t change the situation or state of an object. Challenge 1.4: Exploring the mutator method Our MyDodo has been programmed to do several things. You can let her do things (give her commands) by calling her mutator methods. a) Right-click on Mimi. You will see a list of all the things Mimi can do (in other words, which methods you can call), for example move ( ), and hatchegg ( ). Name one other method which makes Mimi do something. b) Drag Mimi to the centre of the world. Call Mimi s method void move ( ). Can you describe what the method does? i. Drag Mimi to the edge of the world, facing outwards. Call Mimi s method void move ( ) again. What happens now? Tip: to get rid of the pop-up dialogue, click either Reset or Run. ii. Using what you have just seen, match A, B and C in the flowchart in figure 18 to its corresponding code. Algorithmic thinking and structured programming (in Greenfoot) 16

19 Figure 18: Flowchart and code for MyDodo s move ( ) method Please read Theory 1.5: Classes and inheritance. Challenge 1.5: Inheritance We will now have a look at the methods which a MyDodo inherits from the Dodo family. a) Mimi is a MyDodo. All MyDodos are Dodos. Have a look at the class diagram on the right of the screen. Which other is-a relationships do you see? Name at least two. b) Mimi (who is a MyDodo), can do everything a Dodo can do. Right-click on Mimi (in the world). Click on inherited from Dodo. More methods appear, such as layegg ( ). Check that Mimi can execute the layegg (). c) Name two other methods which Mimi the MyDodo inherits from the Dodo class. d) In addition to Dodo methods, Mimi can do a few specific things that only MyDodo can do. Find a method which only MyDodo s have (and Dodos don t). We have now seen that Mimi (and all other MyDodos) inherit and thus can execute all Dodo methods. Please read Theory 1.6: The state of an object. Challenge 1.6: States Every object has a state. We will now have a look at how you can Inspect the states of objects. a) Drag Mimi into the world. Right-click on Mimi and select Inspect. What are her (int x and int y) coordinates? b) Investigate what the coordinates are at each of the corners. Draw in the coordinates in figure 19. The top-left corner has already been done for you. Algorithmic thinking and structured programming (in Greenfoot) 17

20 Figure 19: Coordinates in the world Please read Theory 1.7: Parameters and results. Please read Theory 1.8: Signatures. Challenge 1.7: Calling Accessor Methods In challenge 1.6 we saw that you can use Inspect to get information about Mimi s state. Accessor methods are used to return this information. Let s have a look at how this works. a) Right-click on Mimi. b) Which Dodo class methods return the coordinates of an object? Challenge 1.8: Using Parameters Let s have a look at a few examples of methods with parameters. a) Place Mimi somewhere in the middle of the world. Right-click on Mimi. Call the method jump ( int distance ). This method requires an int (whole number) as a parameter so that it knows how far (distance) Mimi must jump. Type in a small number and see what happens. b) Call the method jump ( int distance ) again. This time use a large number, such as 20, as the parameter. What happens? Can you explain why? c) What happens when you type something in that is not an int (whole number), such as 2.5? What error message do you get? What does this mean? (Tip: have a look at section Theory 1.13) d) If you type in a word as a parameter, instead of a number, you get an error message like in figure 20. Why does the error say something about a String? Figure 20: Error message when using text as a parameter Algorithmic thinking and structured programming (in Greenfoot) 18

21 Please read Theory 1.9: Reading flowchart and code. Challenge 1.9: Reading a flowchart and its corresponding code We will now look at the canlayegg ( already. ) method. Mimi can only lay an egg if there isn t an egg there a) Open MyDodo s code in the editor: Right-click MyDodo in the class diagram and select Open editor. b) Find the canlayegg ( ) method. Tip: use Ctrl+F. c) Have a look at the code for the boolean canlayegg ( ) method in figure 22. The flowchart in figure 21 on the left visualizes the algorithm. Fill in the missing gaps for A,B,C,D (in the flowchart) and E (in the code). d) Remove the comments in front of the code. e) In the code fill in E. f) Test your method. Algorithmic thinking and structured programming (in Greenfoot) 19

22 Figure 21: Flowchart for canlayegg ( ) method Figure 22: Code for canlayegg ( ) method Please read Theory 1.10: Java Documentation. Please read Theory 1.11: Modifying, compiling and testing programs. Please read Theory 1.12: Naming conventions. Challenge 1.10: Adding a new method turn180() We are now going to add a new method to MyDodo which makes Mimi turn 180 around. Figure 23: Flowchart and code for turn180 a) Have a look at the flowchart and its code. Fill in the missing gaps for A and B. b) Open the MyDodo class code in the editor. c) Write the code for the method turn180. d) Compile the code by pressing on the Compile button in the top-left part of the screen (see figure 24). Algorithmic thinking and structured programming (in Greenfoot) 20

23 If necessary fix any mistakes. Figure 24: Compile button e) Call your new method by right-clicking on Mimi and selecting void turn180 ( ). Test if it works as expected. Also test if the other methods still work correctly. In other words, check if the program as a whole still works as expected. f) Add comments above the turn180 ( ) method explaining what the method does, and what the initial and final situations are. Tip: Theory 1.10 explains how to add JavaDoc comments to code. Please read Theory 1.13: Errors. Challenge 1.11: Error messages The compiler is very picky. If you make a mistake in the code or forget something, the compiler will complain. It s useful to be able to recognize some common mistakes and error messages so that you can easily find the problem and fix it. Let s have a look at a few. a) Open the MyDodo class in the editor and find your method turn180 ( ). b) For each of the following, make the changes described, compile, and match the error message to the error in the code. Then fix the error in the code again. i. Delete a semi-colon ; behind turnright ( ); ii. Change the spelling of turn180 ( ) iii. Change turn180 ( ) into turn180 (5) iv. Remove the { after turn180 ( ) v. Remove the ) in turn180 ( ) vi. Remove the ( ) in turn180 ( ) Problem Error message ; expected ( expected method cannot be applied to given types invalid method declaration ) expected cannot find symbol 3. Fix the errors and test if the program still works as expected. Please read Theory 1.14: Printing to the console. Challenge 1.12: Printing text to the console Printing to the console (a separate window) can be useful for testing. a) Find the code for your turn180 ( ) method. Algorithmic thinking and structured programming (in Greenfoot) 21

24 b) Add the following print-to-console statement near the end of the method: System. out. println ( I just turned 180 degrees ); c) Execute your method by right-clicking on Mimi and calling turn180. Note: the console window may be hidden behind one of your other windows. You have now seen how to write code to print a text. Challenge 1.13: Printing variables to the console Printing to the console (a separate window) can be useful for testing. a) Find the code for MyDodo s jump ( ). b) The code doesn t correspond to the flowchart in figure 25. The difference is that the flowchart shows a print-to-console statement in the repeat-block. Figure 25: Example flowchart for printing text to the console c) Use System. out. println ( "moved " + nrstepstaken ); to add the print-to-console statement in the appropriate place in the code. d) Execute your method by right-clicking on Mimi and calling jump. Note: the console window may be hidden behind one of your other windows. e) Test your method using several different values. You have now seen how to write code to print both text and a variable to a console. Challenge 1.14: Printing coordinates to the console The mission is: Mimi walks across her row printing her coordinates to the console at each step. Algorithmic thinking and structured programming (in Greenfoot) 22

25 a) Add the code for printing the coordinates. b) Test your method. Does it also print the last coordinate? c) Fix the flowchart and code. Also add (JavaDoc) comments to your code. You have now written your own method and used a print statement to test if it works appropriately. Algorithmic thinking and structured programming (in Greenfoot) 23

26 Reflection In this assignment you have become acquainted with Greenfoot. You have also been introduced to code. You adjusted code yourself, and practiced compiling and testing each small change that you made. One of the most important steps in becoming good at anything is to evaluate and reflect on what you did and how it went. Take one of the challenges in mind that you are proud of to reflect on. Result I know my solution works because... I am proud of my solution because... I could improve my solution by... Method My approach was good because... What I could do better next time is... Fill the following table with smileys indicating how things went. I can do it I did it a bit but didn t fully get it I didn t get it at all I can find my way around the Greenfoot environment I can explore which methods an object has and call (invoke) these I can explain the relationship between an algorithm, its flowchart and its code Given a method, I can find the code in the Greenfoot editor I can incrementally make changes to code I can add a method, compile, run and test I can recognize error messages Algorithmic thinking and structured programming (in Greenfoot) 24

27 Diagnostic Test Here are sample answers to the questions in the diagnostic test: 1. Which of the following is an int (more than one answer is possible): (a) getnrofeggshatched () (b) 4 (c) 3.2 (d) four (e) -3 (f) 0 (g) False 2. True or false? (a) boolean canmove () is an accessor method; (b) move () is an accessor method; (c) jump ( int distance ) is a mutator method. 3. Explain in your own words what a result type is. Give an example. 4. Match up numbers 1 through 6 in the flowchart in figure 26 with their corresponding parts of code. Figure 26: Code for MyDodo s move () method 5. Name a method that belongs to MyDodo but not to Dodo. 6. Have a look at the following class diagram: Figure 27: Class diagram Algorithmic thinking and structured programming (in Greenfoot) 25

28 (a) Fill the class diagram with the following class names: Kangaroo Lion ZooAnimal (b) Add the following methods to the corresponding superclass or subclasses: hop ( ) sleep ( ) roar ( ) eatmeat ( ) (c) Name all the methods which a Kangaroo can use. 7. What are the coordinates in the bottom-left corner? 8. Complete the table below. Method Result type Parameter type Belongs to class To be used by object getnrofeggshatched () none MyDodo MyDodo canmove () boolean jump () layegg () void turnleft () Dodo and MyDodo canmove () MyDodo getx () 9. Below are some names for a method which returns the number of eggs found. According to the naming conventions for methods names, which one is the best? (a) nrofeggs (b) nrofeggsfound (c) setnrofeggsfound (d) getnrofeggsfound 10. Below are some names for a method. According to the naming conventions for method names, which one is the best? (a) walk_to_egg (b) eggwalker (c) WalkToEgg (d) walktoegg (e) WALK_TO_EGG 11. Below are some names for a parameter indicating the number of eggs. According to the naming conventions for parameter names, which one is the best? (a) nr_of_eggs (b) EggCounter (c) nrofeggs (d) eggs (e) NR_OF_EGGS Algorithmic thinking and structured programming (in Greenfoot) 26

29 12. Here is code for a new method: public A movedown ( ){ turnright ( ) ; move ( ) ; B } The corresponding flowchart is: Figure 28: Flowchart for movedown () (a) Fill in A, B, C, D, E, F and G in the code and the flowchart. (b) What is the method s signature? Saving and Handing in You have just finished the assignment. Save your work! You will need this for future assignments. In the Greenfoot menu at the top of the screen, select Scenario and then Save. You now have all the scenario components in one folder. The folder has the name you chose when you selected Save As.... Handing in Hand in the following: Your name(s): you and your partner; Your code: The java file MyDodo. jav; Flowcharts: paste (photo s of) your flowcharts in a Word document; The reflection sheet: complete and hand it in. Algorithmic thinking and structured programming (in Greenfoot) 27

Assignment 1: Meet Dodo

Assignment 1: Meet Dodo Assignment 1: Meet Dodo Algorithmic Thinking and Structured Programming (in Greenfoot) c 2015 Renske Smetsers-Weeda & Sjaak Smetsers Licensed under the Creative Commons Attribution 4.0 license, https://creativecommons.org/licenses/by/4.0/

More information

Assignment 4: Dodo gets smarter

Assignment 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 information

Assignment 6: Dodo keeps getting smarter

Assignment 6: Dodo keeps getting smarter Assignment 6: Dodo keeps getting smarter Algorithmic Thinking and Structured Programming (in Greenfoot) c 2015 Renske Smetsers-Weeda & Sjaak Smetsers Licensed under the Creative Commons Attribution 4.0

More information

Assignment 3: Optimizing solutions

Assignment 3: Optimizing solutions Assignment 3: Optimizing solutions Algorithmic Thinking and Structured Programming (in Greenfoot) c 2015 Renske Smetsers-Weeda & Sjaak Smetsers Licensed under the Creative Commons Attribution 4.0 license,

More information

Assignment 8: Sokoban

Assignment 8: Sokoban Assignment 8: Sokoban Algorithmic Thinking and Structured Programming (in Greenfoot) c 2015 Renske Smetsers-Weeda & Sjaak Smetsers Licensed under the Creative Commons Attribution 4.0 license, https://creativecommons.org/licenses/by/4.0/

More information

Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers

Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers Computational thinking Working in a structured manner: Breaking problems down into subproblems

More information

Assignment 7: Dodo s Race

Assignment 7: Dodo s Race Assignment 7: Dodo s Race Algorithmic Thinking and Structured Programming (in Greenfoot) c 2015 Renske Smetsers-Weeda & Sjaak Smetsers Licensed under the Creative Commons Attribution 4.0 license, https://creativecommons.org/licenses/by/4.0/

More information

Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers Sjaak Smetsers

Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers Sjaak Smetsers Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers Sjaak Smetsers Today s Lesson plan (3) 10 min Looking back What did we learn last week? Blocks of: Theory Exercises

More information

Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers Ana Tanase

Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers Ana Tanase Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers Ana Tanase Today s Lesson plan (3) 10 min Looking back What did we learn last week? Discuss

More information

The first program: Little Crab

The 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 information

Getting to know Greenfoot

Getting 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 information

Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers Ana Tanase

Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers Ana Tanase Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers Ana Tanase Today s Lesson plan (10) Retrospective Previous lesson Theory: Nested if.. then..

More information

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

CMSC 201 Fall 2016 Lab 09 Advanced Debugging CMSC 201 Fall 2016 Lab 09 Advanced Debugging Assignment: Lab 09 Advanced Debugging Due Date: During discussion Value: 10 points Part 1: Introduction to Errors Throughout this semester, we have been working

More information

Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers

Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers Assignment 5: difficulties Write a method int degreesneededtoturntofacenorth( ) which returns

More information

1 Getting started with Processing

1 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 information

Laboratory 1: Eclipse and Karel the Robot

Laboratory 1: Eclipse and Karel the Robot Math 121: Introduction to Computing Handout #2 Laboratory 1: Eclipse and Karel the Robot Your first laboratory task is to use the Eclipse IDE framework ( integrated development environment, and the d also

More information

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014 Lesson 10A OOP Fundamentals By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Definition Pointers vs containers Object vs primitives Constructors Methods Object class

More information

The compiler is spewing error messages.

The compiler is spewing error messages. Appendix B Debugging There are a few different kinds of errors that can occur in a program, and it is useful to distinguish between them in order to track them down more quickly. Compile-time errors are

More information

Excel Basics: Working with Spreadsheets

Excel 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 information

Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers Ana Tanase

Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers Ana Tanase Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers Ana Tanase Today s Lesson plan (4) 20 min Quiz 10 min Looking back What did we learn last week?

More information

Programming Using C# QUEEN S UNIVERSITY BELFAST. Practical Week 7

Programming Using C# QUEEN S UNIVERSITY BELFAST. Practical Week 7 Programming Using C# QUEEN S UNIVERSITY BELFAST Practical Week 7 Table of Contents PRACTICAL 7... 2 EXERCISE 1... 2 TASK 1: Zoo Park (Without Inheritance)... 2 TASK 2: Zoo Park with Inheritance... 5 TASK

More information

Chapter 4 Defining Classes I

Chapter 4 Defining Classes I Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the

More information

ALICE: An introduction to progamming

ALICE: An introduction to progamming ALICE: An introduction to progamming What is Computer Science? Computer Science Do you know the difference between ICT and Computer Science? Any suggestions as to what jobs you could do if you were a Computer

More information

Initial Coding Guidelines

Initial 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 information

A A B U n i v e r s i t y

A A B U n i v e r s i t y A A B U n i v e r s i t y Faculty of Computer Sciences O b j e c t O r i e n t e d P r o g r a m m i n g Week 4: Introduction to Classes and Objects Asst. Prof. Dr. M entor Hamiti mentor.hamiti@universitetiaab.com

More information

Chapter 1: First Steps to Greenfoot 1

Chapter 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 information

Programming for Beginners

Programming for Beginners Programming for Beginners Learn to Code by Making Little Games Tom Dalling This book is for sale at http://leanpub.com/programming-for-beginners This version was published on 2018-02-23 This is a Leanpub

More information

Improving the Crab more sophisticated programming

Improving 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 information

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA 1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared

More information

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications Hello World! Computer Programming for Kids and Other Beginners by Warren Sande and Carter Sande Chapter 1 Copyright 2009 Manning Publications brief contents Preface xiii Acknowledgments xix About this

More information

CS 251 Intermediate Programming Methods and Classes

CS 251 Intermediate Programming Methods and Classes CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

CS 251 Intermediate Programming Methods and More

CS 251 Intermediate Programming Methods and More CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

Excel 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 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 information

Procedures: Algorithms and Abstraction

Procedures: Algorithms and Abstraction Procedures: Algorithms and Abstraction 5 5.1 Objectives After completing this module, a student should be able to: Read and understand simple NetLogo models. Make changes to NetLogo procedures and predict

More information

ASCII Art. Introduction: Python

ASCII Art. Introduction: Python Python 1 ASCII Art All Code Clubs must be registered. Registered clubs appear on the map at codeclub.org.uk - if your club is not on the map then visit jumpto.cc/18cplpy to find out what to do. Introduction:

More information

CS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class

CS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class CS112 Lecture: Defining Classes Last revised 2/3/06 Objectives: 1. To describe the process of defining an instantiable class Materials: 1. BlueJ SavingsAccount example project 2. Handout of code for SavingsAccount

More information

We will work with Turtles in a World in Java. Seymour Papert at MIT in the 60s. We have to define what we mean by a Turtle to the computer

We will work with Turtles in a World in Java. Seymour Papert at MIT in the 60s. We have to define what we mean by a Turtle to the computer Introduce Eclipse Create objects in Java Introduce variables as object references Aleksandar Stefanovski CSCI 053 Department of Computer Science The George Washington University Spring, 2010 Invoke methods

More information

Java Programming Constructs Java Programming 2 Lesson 1

Java Programming Constructs Java Programming 2 Lesson 1 Java Programming Constructs Java Programming 2 Lesson 1 Course Objectives Welcome to OST's Java 2 course! In this course, you'll learn more in-depth concepts and syntax of the Java Programming language.

More information

Simulations How To for Fathom

Simulations How To for Fathom Simulations How To for Fathom. Start by grabbing a collection box (the picture of a treasure box) and drop it on your screen. You can double click on the word collection to rename it. 2. Click on your

More information

COMP 250 Winter 2011 Reading: Java background January 5, 2011

COMP 250 Winter 2011 Reading: Java background January 5, 2011 Almost all of you have taken COMP 202 or equivalent, so I am assuming that you are familiar with the basic techniques and definitions of Java covered in that course. Those of you who have not taken a COMP

More information

Get JAVA. I will just tell you what I did (on January 10, 2017). I went to:

Get JAVA. I will just tell you what I did (on January 10, 2017). I went to: Get JAVA To compile programs you need the JDK (Java Development Kit). To RUN programs you need the JRE (Java Runtime Environment). This download will get BOTH of them, so that you will be able to both

More information

Improving the crab: more sophisticated programming

Improving 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 information

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday

More information

Access Intermediate

Access Intermediate Access 2013 - Intermediate 103-134 Advanced Queries Quick Links Overview Pages AC124 AC125 Selecting Fields Pages AC125 AC128 AC129 AC131 AC238 Sorting Results Pages AC131 AC136 Specifying Criteria Pages

More information

Variables, expressions and statements

Variables, expressions and statements Variables, expressions and statements 2.1. Values and data types A value is one of the fundamental things like a letter or a number that a program manipulates. The values we have seen so far are 2 (the

More information

Creating Java Programs with Greenfoot

Creating 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 information

Have the students look at the editor on their computers. Refer to overhead projector as necessary.

Have the students look at the editor on their computers. Refer to overhead projector as necessary. Intro to Programming (Time 15 minutes) Open the programming tool of your choice: If you ve installed, DrRacket, double-click the application to launch it. If you are using the online-tool, click here to

More information

Creating Java Programs with Greenfoot

Creating 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 information

Your First Windows Form

Your First Windows Form Your First Windows Form From now on, we re going to be creating Windows Forms Applications, rather than Console Applications. Windows Forms Applications make use of something called a Form. The Form is

More information

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0 VISUAL GUIDE to RX Scripting for Roulette Xtreme - System Designer 2.0 L J Howell UX Software 2009 Ver. 1.0 TABLE OF CONTENTS INTRODUCTION...ii What is this book about?... iii How to use this book... iii

More information

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet. Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that

More information

1 Getting started with Processing

1 Getting started with Processing cisc3665, fall 2011, lab I.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 information

Compilation and Execution Simplifying Fractions. Loops If Statements. Variables Operations Using Functions Errors

Compilation and Execution Simplifying Fractions. Loops If Statements. Variables Operations Using Functions Errors First Program Compilation and Execution Simplifying Fractions Loops If Statements Variables Operations Using Functions Errors C++ programs consist of a series of instructions written in using the C++ syntax

More information

Jerry Cain Handout #5 CS 106AJ September 30, Using JSKarel

Jerry Cain Handout #5 CS 106AJ September 30, Using JSKarel Jerry Cain Handout #5 CS 106AJ September 30, 2017 Using JSKarel This handout describes how to download and run the JavaScript version of Karel that we ll be using for our first assignment. 1. Getting started

More information

Using Karel with Eclipse

Using Karel with Eclipse Chris Piech Handout #3 CS 106A January 10, 2018 Using Karel with Eclipse Based on a handout by Eric Roberts and Nick Troccoli Once you have downloaded a copy of Eclipse as described on the course website,

More information

Welcome to Computers for ESL Students, 4th Edition

Welcome to Computers for ESL Students, 4th Edition For Review Only. Not To Be Resold. This material has not been through quality assurance and/or proofreading and may contain errors. Welcome to Computers for ESL Students, 4th Edition LOIS WOODEN Manteca

More information

FILE ORGANIZATION. GETTING STARTED PAGE 02 Prerequisites What You Will Learn

FILE ORGANIZATION. GETTING STARTED PAGE 02 Prerequisites What You Will Learn FILE ORGANIZATION GETTING STARTED PAGE 02 Prerequisites What You Will Learn PRINCIPLES OF FILE ORGANIZATION PAGE 03 Organization Trees Creating Categories FILES AND FOLDERS PAGE 05 Creating Folders Saving

More information

On the Web sun.com/aboutsun/comm_invest STAROFFICE 8 DRAW

On the Web sun.com/aboutsun/comm_invest STAROFFICE 8 DRAW STAROFFICE 8 DRAW Graphics They say a picture is worth a thousand words. Pictures are often used along with our words for good reason. They help communicate our thoughts. They give extra information that

More information

Lesson 3: Basic Programming Concepts

Lesson 3: Basic Programming Concepts 3 ICT Gaming Essentials Lesson 3: Basic Programming Concepts LESSON SKILLS After completing this lesson, you will be able to: Explain the types and uses of variables and operators in game programming.

More information

PYTHON YEAR 10 RESOURCE. Practical 01: Printing to the Shell KS3. Integrated Development Environment

PYTHON YEAR 10 RESOURCE. Practical 01: Printing to the Shell KS3. Integrated Development Environment Practical 01: Printing to the Shell To program in Python you need the latest version of Python, which is freely available at www.python.org. Your school will have this installed on the computers for you,

More information

Lua - Instruction Manual

Lua - Instruction Manual Table of Contents: General information...... 2 Embedding in "X Train"...... 2 Syntax of Lua... 4 What commands are available...... 5 General Lua commands... 5 "Train X" specific commands...... 6 Functions...

More information

Introduction to Microsoft Word 2010

Introduction to Microsoft Word 2010 Introduction to Microsoft Word 2010 THE BASICS PAGE 02! What is Microsoft Word?! Opening Microsoft Word! The Title Bar! Page View and Zoom MENUS...PAGE 03! Quick Access Toolbar! The Ribbon! File Tab! Home

More information

Java for Non Majors. Final Study Guide. April 26, You will have an opportunity to earn 20 extra credit points.

Java for Non Majors. Final Study Guide. April 26, You will have an opportunity to earn 20 extra credit points. Java for Non Majors Final Study Guide April 26, 2017 The test consists of 1. Multiple choice questions 2. Given code, find the output 3. Code writing questions 4. Code debugging question 5. Short answer

More information

Major Assignment: Pacman Game

Major Assignment: Pacman Game Major Assignment: Pacman Game 300580 Programming Fundamentals Week 10 Assignment The major assignment involves producing a Pacman style game with Clara using the Greenfoot files that are given to you.

More information

Physics 306 Computing Lab 1: Hello, World!

Physics 306 Computing Lab 1: Hello, World! 1. Introduction Physics 306 Computing Lab 1: Hello, World! In today s lab, you will learn how to write simple programs, to compile them, and to run them. You will learn about input and output, variables,

More information

File Management Tutorial

File Management Tutorial Just a reminder... Files: any individual item on your computer that contains data. E.g. document, photo, spreadsheet, email, PowerPoint, etc. File Management Tutorial Folders: containers for your files

More information

Creating objects TOPIC 3 INTRODUCTION TO PROGRAMMING. Making things to program with.

Creating objects TOPIC 3 INTRODUCTION TO PROGRAMMING. Making things to program with. 1 Outline TOPIC 3 INTRODUCTION TO PROGRAMMING Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared

More information

Problem Solving through Programming with Greenfoot. Mark Lewis

Problem Solving through Programming with Greenfoot. Mark Lewis Problem Solving through Programming with Greenfoot Mark Lewis February 24, 2017 Preface There are two significant goals of this text: to teach basic programming skills and to improve students problem solving

More information

Using Flash Animation Basics

Using Flash Animation Basics Using Flash Contents Using Flash... 1 Animation Basics... 1 Exercise 1. Creating a Symbol... 2 Exercise 2. Working with Layers... 4 Exercise 3. Using the Timeline... 6 Exercise 4. Previewing an animation...

More information

Civil Engineering Computation

Civil Engineering Computation Civil Engineering Computation First Steps in VBA Homework Evaluation 2 1 Homework Evaluation 3 Based on this rubric, you may resubmit Homework 1 and Homework 2 (along with today s homework) by next Monday

More information

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners Getting Started Excerpted from Hello World! Computer Programming for Kids and Other Beginners EARLY ACCESS EDITION Warren D. Sande and Carter Sande MEAP Release: May 2008 Softbound print: November 2008

More information

Contents. How to use Magic Ink... p Creating Magic Revealers (with Magic Ink)... p Basic Containers... p. 7-11

Contents. How to use Magic Ink... p Creating Magic Revealers (with Magic Ink)... p Basic Containers... p. 7-11 Rachel Heroth 2014 Contents Magic Ink: How to use Magic Ink... p. 1-2 Creating Magic Revealers (with Magic Ink)... p. 3-6 Containers: Basic Containers... p. 7-11 Troubleshooting Containers...... p. 12

More information

(Refer Slide Time: 1:27)

(Refer Slide Time: 1:27) Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture 1 Introduction to Data Structures and Algorithms Welcome to data

More information

CS 231 Data Structures and Algorithms, Fall 2016

CS 231 Data Structures and Algorithms, Fall 2016 CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard

More information

Mr. Monroe s Guide to Mastering Java Syntax

Mr. Monroe s Guide to Mastering Java Syntax Mr. Monroe s Guide to Mastering Java Syntax Getting Started with Java 1. Download and install the official JDK (Java Development Kit). 2. Download an IDE (Integrated Development Environment), like BlueJ.

More information

Access Intermediate

Access Intermediate Access 2010 - Intermediate 103-134 Advanced Queries Quick Links Overview Pages AC116 AC117 Selecting Fields Pages AC118 AC119 AC122 Sorting Results Pages AC125 AC126 Specifying Criteria Pages AC132 AC134

More information

Valuable points from Lesson 6 Adobe Flash CS5 Professional Classroom in a Book

Valuable points from Lesson 6 Adobe Flash CS5 Professional Classroom in a Book Valuable points from Lesson 6 Adobe Flash CS5 Professional Classroom in a Book You are expected to understand and know how to use/do each of these tasks in Flash CS5, unless otherwise noted below. If you

More information

Using Microsoft Excel

Using Microsoft Excel Using Microsoft Excel Introduction This handout briefly outlines most of the basic uses and functions of Excel that we will be using in this course. Although Excel may be used for performing statistical

More information

Documentation Requirements Computer Science 2334 Spring 2016

Documentation Requirements Computer Science 2334 Spring 2016 Overview: Documentation Requirements Computer Science 2334 Spring 2016 These requirements are based on official Java coding conventions but have been adapted to be more appropriate to an academic environment.

More information

In this lesson you will learn: How to capture the input from the user. How to write programs using variables and lists. Athletics Swimming Gymnastics

In this lesson you will learn: How to capture the input from the user. How to write programs using variables and lists. Athletics Swimming Gymnastics Lesson 4 A m In this lesson you will learn: How to capture the input from the user. How to write programs using variables and lists. Advanced Scratch Sports Day Jyoti and Tejas are planning to create a

More information

FACULTY AND STAFF COMPUTER FOOTHILL-DE ANZA. Office Graphics

FACULTY AND STAFF COMPUTER FOOTHILL-DE ANZA. Office Graphics FACULTY AND STAFF COMPUTER TRAINING @ FOOTHILL-DE ANZA Office 2001 Graphics Microsoft Clip Art Introduction Office 2001 wants to be the application that does everything, including Windows! When it comes

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

Making use of other Applications

Making use of other Applications AppGameKit 2 Collision Using Arrays Making use of other Applications Although we need game software to help makes games for modern devices, we should not exclude the use of other applications to aid the

More information

Creating Vector Shapes Week 2 Assignment 1. Illustrator Defaults

Creating Vector Shapes Week 2 Assignment 1. Illustrator Defaults Illustrator Defaults Before we begin, we are going to make sure that all of us are using the same settings within our application. For this class, we will always want to make sure that our application

More information

[ the academy_of_code] Senior Beginners

[ 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 information

5.6.1 The Special Variable this

5.6.1 The Special Variable this ALTHOUGH THE BASIC IDEAS of object-oriented programming are reasonably simple and clear, they are subtle, and they take time to get used to And unfortunately, beyond the basic ideas there are a lot of

More information

Outline. Turtles. Creating objects. Turtles. Turtles in Java 1/27/2011 TOPIC 3 INTRODUCTION TO PROGRAMMING. Making things to program with.

Outline. Turtles. Creating objects. Turtles. Turtles in Java 1/27/2011 TOPIC 3 INTRODUCTION TO PROGRAMMING. Making things to program with. 1 Outline 2 TOPIC 3 INTRODUCTION TO PROGRAMMING Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared

More information

How to make a Work Profile for Windows 10

How to make a Work Profile for Windows 10 How to make a Work Profile for Windows 10 Setting up a new profile for Windows 10 requires you to navigate some screens that may lead you to create the wrong type of account. By following this guide, we

More information

Game keystrokes or Calculates how fast and moves a cartoon Joystick movements how far to move a cartoon figure on screen figure on screen

Game keystrokes or Calculates how fast and moves a cartoon Joystick movements how far to move a cartoon figure on screen figure on screen Computer Programming Computers can t do anything without being told what to do. To make the computer do something useful, you must give it instructions. You can give a computer instructions in two ways:

More information

How To Upload Your Newsletter

How To Upload Your Newsletter How To Upload Your Newsletter Using The WS_FTP Client Copyright 2005, DPW Enterprises All Rights Reserved Welcome, Hi, my name is Donna Warren. I m a certified Webmaster and have been teaching web design

More information

Interactive Tourist Map

Interactive 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 information

Outlook Web Access. In the next step, enter your address and password to gain access to your Outlook Web Access account.

Outlook Web Access. In the next step, enter your  address and password to gain access to your Outlook Web Access account. Outlook Web Access To access your mail, open Internet Explorer and type in the address http://www.scs.sk.ca/exchange as seen below. (Other browsers will work but there is some loss of functionality) In

More information

Barchard Introduction to SPSS Marks

Barchard Introduction to SPSS Marks Barchard Introduction to SPSS 22.0 3 Marks Purpose The purpose of this assignment is to introduce you to SPSS, the most commonly used statistical package in the social sciences. You will create a new data

More information

Preprocessor Directives

Preprocessor Directives C++ By 6 EXAMPLE Preprocessor Directives As you might recall from Chapter 2, What Is a Program?, the C++ compiler routes your programs through a preprocessor before it compiles them. The preprocessor can

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

EXCEL BASICS: MICROSOFT OFFICE 2007

EXCEL BASICS: MICROSOFT OFFICE 2007 EXCEL BASICS: MICROSOFT OFFICE 2007 GETTING STARTED PAGE 02 Prerequisites What You Will Learn USING MICROSOFT EXCEL PAGE 03 Opening Microsoft Excel Microsoft Excel Features Keyboard Review Pointer Shapes

More information

CPS122 Lecture: Defining a Class

CPS122 Lecture: Defining a Class Objectives: CPS122 Lecture: Defining a Class last revised January 14, 2016 1. To introduce structure of a Java class 2. To introduce the different kinds of Java variables (instance, class, parameter, local)

More information

Chapter 15: Object Oriented Programming

Chapter 15: Object Oriented Programming Chapter 15: Object Oriented Programming Think Java: How to Think Like a Computer Scientist 5.1.2 by Allen B. Downey How do Software Developers use OOP? Defining classes to create objects UML diagrams to

More information

Grade Point Scales Standard Honors AP/College A B C D F Sample file

Grade Point Scales Standard Honors AP/College A B C D F Sample file 64 Transcripts Weighted Cumulative GPA When your student works extra hard and takes honors or college courses, they deserve a little credit. The best way to reflect this is through their GPA. They deserve

More information

CMPT 100 : INTRODUCTION TO

CMPT 100 : INTRODUCTION TO CMPT 100 : INTRODUCTION TO COMPUTING TUTORIAL #5 : JAVASCRIPT 2 GUESSING GAME 1 By Wendy Sharpe BEFORE WE GET STARTED... If you have not been to the first tutorial introduction JavaScript then you must

More information