DOC PREVIEW
TRINITY CSCI 1311 - Structure of Java Code
Pages 12

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

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 12 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 12 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 12 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 12 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 12 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 12Structure of Java Code1-25-2010Opening Discussion●What did we do last class?●Minute Essay comments–Keeping the details straight.–How do you get images into Greenfoot?–What happens if you put 2 leaves in the same place?–What is the difference between parentheses and curly braces?–How do you know background logic for language?More Minute Essays–Does indentation make a difference?–Is there a guide for the language/punctuation?–Cheat sheets.–Why can't you add alligators or bees into the WombatWorld?–Do comments affect the code?–Additional practice?–Similarities to symbolic logic?–How long did it take me to write this scenario?–What is a constructor?The Structure of a Class●Last time we looked inside of some classes at the code that was present in them. Today we want to be explicit about the structure of Java code, starting with classes.●For the time being all of your classes will have the following structure.public class ClassName [extends SuperClass] {–Methods (things it can do)–Member data (things that it knows)}The Wombat Class●Let's open the Wombat class in PSPGWombat so that we can go through it and see different aspects of the things we are going to talk about today.Curly Braces●Note that the class has curly braces around everything inside the class.●In Java, curly braces are used to group pieces of code together and provide a range or scope over which things can be used.Member Data●These are the things that an object of a class will “know”.●We will always make these private.●The declaration has the following form–private Type name[=expression];●Type can either be a primitive, like int or boolean, or it can be the name of a class.●Names begin with a letter followed by zero or more letters and numbers. Use camel naming.Methods●These are the things that an object of this class can do.●Most of these will be public.●The declaration has the following form–public Type name([Type name[, Type name, ...]) {●statements–}●The statements in the method are executed in order.Statements●There are ten different types of statements in Java. We will only deal with four of those right now.–Variable declaration–Assignment–Method call–Return statement●All four are followed by a semicolon.Writing our Code●Pull down the city scenario from the web site and open it.●I would like to make it so that when a city is created it has a person and a building.●I would also like it if the person would move when the act method is called.●How are we going to make these things happen?The API●Using right click to see what methods something has is not only time consuming, it doesn't give you great descriptions.●Go to the Greenfoot site > For Programmers > Greenfoot API (online).●API stands for Application Programming Interface. It documents the methods and members of classes.Minute Essay●What questions do you have about the things that we talked about today?●Keep in mind that the first round of interclass problems will be next


View Full Document

TRINITY CSCI 1311 - Structure of Java Code

Course: Csci 1311-
Pages: 12
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 Structure of Java Code
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 Structure of Java Code 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 Structure of Java Code 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?