User:Valerie Hagen
From ggc
Notes
Study Guide - Test 1
1. Study Tutorial/Program Structure page under javawide or wiki a. Study terms b. Key words (change color or always lower case) public, void, key words relate to identifiers - exclusive - i. Name of special meaning in program ii. One word iii. Need to know: void; private; import; class c. Identifiers (all names programmers choose - name of the variables)- string; sprite; makeSprites; startGame; addSprites d. Class declaration + class body = class definition i. Same with method and variable e. Method declaration – parenthesis; void – following method declaration there is an {. i. Method definition goes outside the method body ii. Unit called method definition iii. Method name iv. One word 1. ex. advanceFrame 2. Class names – always capitalized a. Example: ProgramSturcture
f. Method Bodies i. Call or invoke method – always has parenthesis 1. Ex: Canvas.addSprite(square);
g. Variable declaration – type followed by variable name i. ex: private Sprite oval; ii. Naming a Variable- all lowercase 1. example: oval
Side Notes:
Access Specifier (modifier) outside the class - public
Non " " - private
• Conventions - naming (depends on what u name it - Capitalized -- always • Method naming - lower case then Capital letter makeSprites • Variable-lower case Upper case • Spacing convention - indent after brace, brace on one line by itself, statements go on line by themselves. • */ -- Comments; end with -- *\ • If your parenthesis do not match up, brackets don’t match up, quotes, = a problem etc. • Parameter list - in between parenthesis • Field declation - ex: private Sprite oval;
Debugging- program compiles but doesnt do what u want it to do; "fix the bug"
RUN TIME ERRORS: screen jumps in half -- nol pointer acception - try to use a variabel before you initialize it • Spacing Convention – indent after brackets only put braces on line by itself. o Example: public void startGame;
{
makeSprites();
addSprites();
}
b4 use variable - declare it then initialize it with in the method body then call it
give a starting value until you use it - n something literal - assignment identifier declaring a method conditional execution ... where the player clicks != null (doesnt exsist) new= calling a constructer 1 package Jam;
2 import fang.*;
3 /**
4 * All about my class here.
5 * @author Jam Jenkins
6 */
7 public class HelloGame extends GameLoop
8 {
9 private Sprite hello;
10
11 public void startGame()
12 {
13 hello=new StringSprite("Hello World");
14 hello.setLocation(0.5, 0.5);
15 canvas.addSprite(hello);
16 }
17 public HelloGame()
18 {
19
20 }
21 }
22
Main definitions:
Identifier- name given by the game (can’t have spaces) *Names cant have spaces also* When you call a method you have parentheses String- sequence of characters
Unit - public class HelloGame extends GameLoop- Class declaration
Hellogame- name of the program
Extends- everything from basic game and more.
Public- everyone can view
GameLoop- the game loops
Ex. Field - private Sprite hello; Private- only some can see Sprite- object Hello- identifier outside the name block people cant see.
2 methods: public void startGame()- start of a method Identify method always followed by a code block
Method Body: hello=new StringSprite("Hello World"); 14 hello.setLocation(0.5, 0.5); Location of opject 15 canvas.addSprite(hello);
int (declare) x=5 (initialize);
if (x==5) (comparison - determining if x is 5)
{
System.out.println ("Howdy!); TRUE
} else {
System.out.printl("Bye!) FALSE
} both statements cannot be at same time only true or false
- This page was last modified on 31 January 2008, at 12:58.
- This page has been accessed 346 times.
- Privacy policy
- About ggc
- Disclaimers
- Powered by MediaWiki!









