TRINITY CSCI 1311 - Keyboard Input (10 pages)

Previewing pages 1, 2, 3 of 10 page document View the full content.
View Full Document

Keyboard Input



Previewing pages 1, 2, 3 of actual document.

View the full content.
View Full Document
View Full Document

Keyboard Input

59 views


Pages:
10
School:
Trinity University
Course:
Csci 1311 -
Documents
Unformatted text preview:

Keyboard Input 2 4 2009 Opening 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 this


View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

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 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?