DOC PREVIEW
TRINITY CSCI 1311 - Keyboard Input
Pages 10

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

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 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 10 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 10 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Keyboard Input2/4/2009Opening Discussion●Minute Essay responses–Fuzzy logic–Variable names, different names for the same things?–Order of statements in methods is important. They happen in the order you write them. Order of methods doesn't matter.–We ignored the boolean return on enterHouse.–enterHouse always happens. Doesn't do anything if not on the house.More Responses–Boolean logic can be confusing, requires some thought. Definitely expands our options.–Role of the getWorld() method.–Can you nest if statements?–Can multiple people enter different houses in the world?Goal for the Day●Today I want to make it so that you can control the movement of the person on the screen with the arrow keys.●How should we go about doing this?Keyboard Input●If you look in the API you will find that the Greenfoot class has a method called getKey().●What is the return type of this method? What does the API say the value of this return will be?Strings●A string is a sequence of characters. Words and sentences are strings.●The type of strings in Java is String. Note it starts with a capital letter.●We write string literals in Java by putting whatever we want in quotes.●The web page has a link to the API page for String.Key Methods of String●equals(String s) - This was mentioned last class as the proper way to compare object types.●length() - Returns the number of characters in the string.●indexOf(...) - Many options for arguments. Returns the location in the string where first found.●+ - Not really a method. The plus sign is overloaded in Java to do String concatenation.Printing●Sometimes you need more information than what is being displayed on the world to figure out what a program is doing.●You can print and whatever you print will appear in the console.●To do this use the System.out.println() method. You can pass it one argument of basically any type.Writing the Code●Now we can make it so that the person moves based on keyboard input.●Where should this code go?●What should it look like?Minute Essay●Do you have any questions about what was covered today? Is it clear how to use keyboard input in Greenfoot?●Feel free to do multiple interclass problems. Practice is key to learning


View Full Document

TRINITY CSCI 1311 - Keyboard Input

Course: Csci 1311-
Pages: 10
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 Keyboard Input
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 Keyboard Input 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 Keyboard Input 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?