DOC PREVIEW
TRINITY CSCI 1311 - Interacting with Objects
Pages 14

This preview shows page 1-2-3-4-5 out of 14 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Interacting with Objects8-30-2010Opening Discussion●Have you come up with any questions about the class since last time?●Minute essay responses:–Finding people to help you.–Is this going to something anyone can learn?–Does Greenfoot work with Vista?–What version of Mac do you need for things to work?More Minute Essays–Where to get Greenfoot. Is it free?–Will this class help you write programs to analyze statistics in the economy?–How do you create scenarios in Greenfoot?Greenfoot●Let's run Greenfoot and open up the PSPGWombats scenario.●Greenfoot environment has several parts to it.–Shows a 2-D graphical display in the main area. –Elements that make things active at at the bottom.–List of different classes are on the right.Classes and Objects●Java is a class-based object-oriented programming languages. We write classes and those are the blueprints for making objects.●Greenfoot groups different classes: World, Actor, Others.●We can tell Greenfoot to make a new Actor object from a class either with a right-click or holding shift.Methods●Classes have methods in them and these methods can be called on the objects of that class.●Right click on “wombatWorld” at the top to call a method on the WombatWorld object. Right click on one of the objects to call a method on it.●Methods can cause things to happen or give us back information.Parameters and Return Types●Some methods need extra information. This is passed in through parameters.–The setDirection method in Wombat needs to be told a direction.●Some methods give you back information.–The getLeavesEaten method in Wombat tells you how many leaves have been eaten.●The “signature” of a method begins with the return type then has the method name and an argument list in parentheses.Types●If you go through all the options on the Wombat when you right click you will see a number of different types.–int: for numbers that don't have fractions.–boolean: either true of false.–String: any text you want.–GreenfootImage and World: types specific to Greenfoot.●Other types include double and char.●Classes define types.Act and Run●At the bottom of the window is an area that has a few buttons. All the actors in Greenfoot have a method called act.●Clicking the Act button calls that method on all the actors.●Clicking Run will repeatedly call the act method.Member Data●Objects can hold information as well. These are called members.●You can look at what is stored by an object by selecting inspect from the right-click menu.●Arrows are drawn when members store other objects. In Java object types are often called reference types.Solving a Problem●I want to make the Wombat eat all the leaves on the screen.●What series of instructions would you give the Wombat to make this happen?Generality●Is the series of instructions you came up with general? If we moved the leaves, would it still work?●Generality is something that we typically strive for in the code that we write. It often shortens how much total code we need to create or how often we have to edit things.Optimality●Was your method of eating all the leaves optimal? Was there a shorter set of instructions that would have accomplished the same task?●Optimality is a secondary goal for most code.●Programs can also be used to help us determine if solutions are optimal.Minute Essay●Do you have any questions about the topics we discussed


View Full Document

TRINITY CSCI 1311 - Interacting with Objects

Course: Csci 1311-
Pages: 14
Documents in this Course
Arrays

Arrays

12 pages

Arrays

Arrays

10 pages

Applets

Applets

5 pages

Arrays

Arrays

8 pages

Methods

Methods

12 pages

Drawing

Drawing

8 pages

Load more
Download Interacting with Objects
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Interacting with Objects and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Interacting with Objects 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?