Assignment 3 Little Crab Part 1
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:
- Read the statements and questions below.
- Complete the activities as described in each statement.
- You can use this document for answering the questions. Include your name, period, and date in the document.
- 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.
- Use this document to answer the questions below, using different font and Bold.
- 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.”
- Download to your desktop, and thenOpen a Copy of the little-crab scenario from Mr. Gonzalez Website, Using the Greenfoot program.
- Read section 2.1 of the text.
- What do you observe when you complete exercise 2.1?
- Why does the Crab behave as you observe when you complete exercise 2.1?
- Read section 2.2, complete the exercises, and answer these questions.
- What are you looking at when you open the editor of the Crab class, or any other class?
- What does the Crab class definition do?
- What is the method in the class definition?
- 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.
- What is the difference between clicking the Act and Run buttons?
- What is a method call?
- What do you observe when the crab moves? What are the limits of the move() method?
- 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.
- What does the method call turn(90) mean?
- How do you make the crab turn left?
- 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.
- 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.
- 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.
- When you get an error message how can you get more information about the error?
- 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.
- Read section 2.4, complete the exercises, and answer these questions.
- How do you see what methods are available for a class?
- Why is it important to see the methods that a class has available?
- Where does the Crab class get all its methods?
- How do you switch between source code and documentation view?
Complete exercise 2.9 in the blue box on page 22 before going on.
- What is the signature for the method that determines if a crab is at the edge of the world?
- Does this method have parameters? Why do some methods have parameters and others do not?
- What is the return type of atWorldEdge() ?
- Complete exercise 2.10. What does AtWorldEdge() return?
- Complete exercise 2.11. What does it return now?
- Read the information on page 24 about if-statements. What does an if-statement do?
- What happens when the condition in an if-statement is false?
- Complete exercise 2.12 to make your crab turn when it is at the edge of the screen.
- Complete exercise 2.13.
- Complete exercise 2.14. Why does the crab behave this way?
- 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.
- 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.