Sunteți pe pagina 1din 2

Name:__________________ Date:____________

Introduction to Computer Science 1.1 to 1.4 Notes

Directions: Answer the following questions. Make sure you understand the topics being covered. You are going to need to open the scenario leaves-and-wombats. This can be found on the public drive, near the dropbox folder. Copy the entire folder onto your network drive. 1. Define the following: a. World: the largest area of the screen; where everything happens b. class diagram the area of the right of the screen and shows us the classes involved in our scenario c. execution controls buttons on the bottom of the screen that allows us to run, reset, and act the program 2. Java is an object oriented language. 3. Once you have a class in Greenfoot, you can create objects or instances from it. 4. Another name for objects is instances 5. When you right click on the WOMBAT class, you will see the class menu pop up. Exercise 1.1: Create some more wombats in the world. Create some leaves. 6. How can you interact with these objects? Right click 7. Define object menu. A menu that shows us all the operations a specific object can perform 8. Inspect, remove, move, turnLeft are what type of operations? Invoking the method Exercise 1.2: Invoke the move() method on a wombat. What does it do? Try it several times. Invoke the turnLeft() method. Place two wombats into your world and make them face each other. The move method makes the wombat move forward one space in a forward direction 9. When you look at the methods void move() and void turnLeft(), there is the world VOID at the beginning and a pair of parentheses at the end. What does this tell us? They tell us what type of information is returned and what data is going into the method

10. What do you call the word at the beginning? What does it tell us? It is called the return type and it tells us what the method returns when it is invoked 11. What does the word void mean? It means nothing in this context 12. What does the word int mean? interger 13. What does the world Boolean mean? True or false 14. Methods with non-void return types are like questions Exercise 1.3: Invoke the canMove() method on your wombat. Does it always return true? Or can you find situations in which it returns false? When is it false? It does not always return true. When it hits the wall, it will return false.

Exercise 1.4: Using a newly created wombat, the getLeavesEaten() method will always return zero. Can you create a situation in which the results of this method is not zero? When the wombat eats a leaf, then the number will increase corresponding to the number of leaves eaten

Once you complete the following worksheet, make sure you save it as ( LastName.1.1-1.4 Important vocabulary). Play around with the program. Try different things out. Experiment with Greenfoot!

S-ar putea să vă placă și