Computer Programming 1A

Assignment 3 – Little Crab Part 1


In this activity you will:

  • Use the Greenfoot Electronic Book to begin writing Java code.
  • Answer questions about the material in the book.
  • Practice critical thinking through reading, writing, and speaking.

Algorithm for this activity:

  1. Read the statements and questions below.
  2. Complete the activities as described in each statement.
  3. You can use this document for answering the questions. Include your name, period, and date in the document.
  4. Turn-in your work to Period 4 -- Computer Programming & Game Design Assignments ONLYwith the filename #-CP1-Assn3-Last,First

All answers in 3 or more completed sentences.

  1. Use this document to answer the questions below, using different font and Bold.
  2. In the Mr. Gonzalez Website, locate the Electronic Textbook and open the Text – Introduction to Programming with Greenfoot Part III Open the book to chapter 2, “The first program: Little Crab.”
  1. Download to your desktop, and thenOpen a Copy of the little-crab scenario from Mr. Gonzalez Website, Using the Greenfoot program.
  1. Read section 2.1 of the text.
  2. What do you observe when you complete exercise 2.1?
  1. Why does the Crab behave as you observe when you complete exercise 2.1?
  1. Read section 2.2, complete the exercises, and answer these questions.
  2. What are you looking at when you open the editor of the Crab class, or any other class?
  1. What does the Crab class definition do?
  1. What is the method in the class definition?
  1. What do we call the curly braces and anything between them?

Do Exercises 2.2 and 2.3 on page 19 (in the blue box) before answering e.

  1. What is the difference between clicking the Act and Run buttons?
  1. What is a method call?
  1. What do you observe when the crab moves? What are the limits of the move() method?
  1. Read section 2.3 of the text, complete the exercises, and answer these questions.

Complete exercises 2.4 and 2.5 in the blue box on page 20 before answering the questions.

  1. What does the method call turn(90) mean?
  1. How do you make the crab turn left?
  1. What is the number in the parentheses in the turn(90) instruction called?

Make the crab move in larger and smaller circles by changing the parameter in the turn method.

  1. What is the difference between using larger and smaller numbers in the turn method?

Read the gray box titled Terminology on page 20 before answering question e.

  1. Why does move() not require a parameter while turn(N) does?

Complete Exercise 2.7 in the blue box on page 21 before going on.

  1. When you get an error message how can you get more information about the error?
  1. At this point your crab should move and turn using the code in code 2.2 on page 20 of the text. If not, turn to that page and make sure you have completed the exercises.
  2. Read section 2.4, complete the exercises, and answer these questions.
  3. How do you see what methods are available for a class?
  1. Why is it important to see the methods that a class has available?
  1. Where does the Crab class get all its methods?
  1. How do you switch between source code and documentation view?

Complete exercise 2.9 in the blue box on page 22 before going on.

  1. What is the signature for the method that determines if a crab is at the edge of the world?
  1. Does this method have parameters? Why do some methods have parameters and others do not?
  1. What is the return type of atWorldEdge() ?
  1. Complete exercise 2.10. What does AtWorldEdge() return?
  1. Complete exercise 2.11. What does it return now?
  1. Read the information on page 24 about if-statements. What does an if-statement do?
  1. What happens when the condition in an if-statement is false?
  1. Complete exercise 2.12 to make your crab turn when it is at the edge of the screen.
  1. Complete exercise 2.13.
  1. Complete exercise 2.14. Why does the crab behave this way?
  1. At this point you should have completed all the exercises (in the blue boxes in the text) through Exercise 2.14 and your crab should move and turn even when it reaches the edge of the world.
  1. SAVE your functioning scenario to your Box account. You will be adding to it in the next exercises!

To save Greenfoot scenarios, just close all the open windows then drag the entire folder to your Box account.

Save this document as #-CP1-Assn3-Last,First and turn-it-in to Mr. Gonzalez’s

Turn-in Assignments for Period - 4 ONLY

  • First, save your answer document with the following format—in your box account:

EXAMPLE: 4-CP&GD-Assign 0 Algorithms -Last,First

#-ClassName-Assignment Name- U'r Last, U'r First

(# - Stands for your period number)

  • Click on the link below (will Start a web browser) to upload your assignment.

Period 4 -- Computer Programming & Game Design Assignments ONLY

  • Choose your file (browse) and click Upload. Do NOT fill anything else once you uploaded, in this window, close it, you are done.