Help with war game

I am learning java and was looking at this program I don't understand what is wrong with it, I am getting an error that says something about the compareTo cannot be found and variable cannot be found.
class Card implements Comparable
Card(int r, int s)
rank = r;
suit = s;
int getRank()
return rank;
int getSuit()
return suit;
public int compareTo(Object ob)
Card other = (Card)ob;
int thisRank = this.getRank();
int otherRank = other.getRank();
if (thisRank == 1) thisRank = 14; // make aces high
if (otherRank == 1) otherRank = 14;
return thisRank - otherRank;
public boolean equals(Object ob)
if (ob instanceof Card)
Card other = (Card)ob;
return value==other.value && suit==other.suit;
else return false;
public String toString()
String val;
String [] suitList =
{ "", "Clubs", "Diamonds", "Hearts", "Spades" };
if (rank == 1) val = "Ace";
else if (rank == 11) val = "Jack";
else if (rank == 12) val = "Queen";
else if (rank == 13) val = "King";
else val = String.valueOf(rank); // int to String
String s = val + " of " + suitList[suit];
for (int k=s.length()+1; k<=17; k++) s = s + " ";
return s;
private int rank;
private int suit;
class CardDeck
CardDeck()
deck = new Card [52];
fill();
void shuffle()
for (int next = 0; next < numCards-1; next++)
int r = myRandom(next, numCards-1);
Card temp = deck[next];
deck[next] = deck[r];
deck[r] = temp;
Card deal()
if (numCards == 0) return null;
numCards--;
return deck[numCards];
int getSize()
return numCards;
private void fill()
int index = 0;
for (int r = 1; r <= 13; r++)
for (int s = 1; s <= 4; s++)
deck[index] = new Card(r, s);
index++;
numCards = 52;
private static int myRandom(int low, int high)
return (int)((high+1-low)*Math.random()+low);
private Card [] deck;
private int numCards;
class Pile
Pile()
pile = new Card[52];
front = 0; end = 0;
int getSize()
return end - front;
void clear()
front = 0; end = 0;
void addCard(Card c)
pile[end] = c;
end++;
void addCards(Pile p)
while (p.getSize() > 0)
addCard(p.nextCard());
Card nextCard()
if (front == end)
return null; // should not happen
Card c = pile[front];
front++;
return c;
private Card [] pile;
private int front, end; // front &#8804; end
class Player
Player(String n)
name = n;
playPile = new Pile();
wonPile = new Pile();
Card playCard()
if (playPile.getSize() == 0)
useWonPile();
if (playPile.getSize() > 0)
return playPile.nextCard();
return null;
String getName()
return name;
void collectCard(Card c)
wonPile.addCard?;
void collectCards(Pile p)
wonPile.addCards(p);
void useWonPile()
playPile.clear(); // reset front and end to 0
playPile.addCards(wonPile);
wonPile.clear(); // reset front and end to 0
int numCards()
return playPile.getSize() + wonPile.getSize();
private Pile playPile, wonPile;
private String name;
class Game
void play()
CardDeck cd = new CardDeck();
cd.shuffle();
p1 = new Player("Ernie");
p2 = new Player("Burt");
while (cd.getSize() >= 2)
p1.collectCard(cd.deal());
p2.collectCard(cd.deal());
p1.useWonPile();
p2.useWonPile();
Pile down = new Pile(); // Pile for cards in a war
loop: for (int t=1; t<=100; t++)
if (!enoughCards(1)) break loop;
Card c1 = p1.playCard();
Card c2 = p2.playCard();
System.out.println("\nTurn " + t + ": ");
System.out.print(p1.getName() + ": " + c1 + " ");
System.out.print(p2.getName() + ": " + c2 + " ");
if (c1.compareTo(c2) > 0)
p1.collectCard(c1); p1.collectCard(c2);
else if (c1.compareTo(c2) < 0)
p2.collectCard(c1); p2.collectCard(c2);
else // War
down.clear();
down.addCard(c1); down.addCard(c2);
boolean done = false;
do
{ int num = c1.getRank();
if (!enoughCards(num)) break loop;
System.out.print("\nWar! Players put down ");
System.out.println(num + " card(s).");
for (int m=1; m<=num; m++)
c1 = p1.playCard(); c2 = p2.playCard();
down.addCard(c1);
down.addCard(c2);
System.out.print(p1.getName()+": "+ c1 + " ");
System.out.print(p2.getName()+": " + c2 + " ");
if (c1.compareTo(c2) > 0)
{ p1.collectCards(down);
done = true;
else if (c1.compareTo(c2) < 0)
{ p2.collectCards(down);
done = true;
while (!done);
} // end of for t=1 to 100
System.out.println(p1.numCards() + " to "
+ p2.numCards());
boolean enoughCards(int n)
if (p1.numCards() < n || p2.numCards() < n)
return false;
return true;
Player getWinner()
if (p1.numCards() > p2.numCards())
return p1;
else if (p2.numCards() > p1.numCards())
return p2;
else
return null;
private Player p1, p2;
public class War
public static void main(String [] args)
Game g = new Game();
g.play();
Player winner = g.getWinner();
if (winner == null) System.out.println("Tie game.");
else System.out.println("\nWinner = "
+ winner.getName());
Message was edited by:
thunderbbolt

return value==other.value && suit==other.suit;I don't see a variable named value defined anywhere either. Do you? I do see rank and suit variables though.

Similar Messages

  • Help with rhythm game

    So i am starting university in late september (to learn 3d character animation) and need to get the grades to get in, sadly we have a flash programming unit in the college course im in now and we didnt get taught anything at all and i mean nothing, we were given printed sheets and told to copy the code word for word. so i really need help with my game. how would i make the movement of something my cursor? so when i move the cursor it follows it? also how do i play an animation on click?
    My  idea for the game is to have a rhythm style game where the player moves the net and catches the bee's, something i thought would be simple to figure out how to do
    This is my game at the minute, ive used the code we were told to copy from sheets and just changed the sprites :\ any help would be amazing!
    https://www.dropbox.com/s/1pjbv2mavycsi3q/sopaceship%20rev7%20%20moving%20bullet.fla

    http://orangesplotch.com/blog/flash-tutorial-elastic-object-follower/
    var distx:Number;
    var disty:Number;
    var momentumx:Number;
    var momentumy:Number;
    follower.addEventListener(Event.ENTER_FRAME, FollowMouse)
    function FollowMouse(event:Event):void {
         // follow the mouse in a more elastic way
         // by using momentum
         distx = follower.x - mouseX;
         disty = follower.y - mouseY;
         momentumx -= distx / 3;
         momentumy -= disty / 3;
         // dampen the momentum a little
         momentumx *= 0.75;
         momentumy *= 0.75;
         // go get that mouse!
         follower.x += momentumx;
         follower.y += momentumy;

  • I need help with ipod games...

    Dear other Itunes users,
    I have multiple libraries that I currently use. The problem is not that I can not successfully get the games on the ipod, but that all the games(purchased on different computers) cannot coexist on the ipod. The message warns me and states that it will replace the other games I purchased with the games from my current library. How can I fix this?
    Thank you, tjd51.

    Use the Transfer Purchases option to place all of the games on one computer, and then sync the games from that computer.
    (30664)

  • Help with j2me games

    I'm a student that needs help for my school thesis.I'm new to j2me. I'm trying to develop a multiplayer game via GPRS. i have a few general question to ask.I',m doing a round robin game.
    1) I saw in the nokia forum about the http server and tcp server. What is the main difference?Isn't the internet stack is divided to application, transport and network layer and so on?why will have http server and tcp server?isn't that tcp connection also implemented in http server?
    2) In the http server, the server won't start a connection with the client. If i send a http request to the server to start a new game with my opponent, how do the server will nodify my opponent?My opponent don't know i'm sending a game to him.
    3) Is that tcp server has already successfully implemented now?Is there any free tcp server or i need to code it in J2se?
    4) Is that using WAP or IP router to send the internet stack to the server?Which 1 is better?

    internet stack is divided to application, transport
    and network layer and so on?Yes, but a mobile might not have a IP stack, instead a simple connection to a proxy server, which "talks" to the net.
    how do the server will nodify my opponent?My opponent
    don't know i'm sending a game to him.Perodic updates (polling).
    3) Is that tcp server has already successfully
    implemented now?I dont understand the question. Has anyone used TCP/IP on mobile phones (as client software), yes me: http://j2mevnc.sourceforge.net
    Has anyone used the serversocket. Other than demo-ware, not that I know of, not many phones support socket://, let alone serversocket://
    4) Is that using WAP or IP router to send the internet
    stack to the server?Which 1 is better?Depends on your need.

  • Please! I need someone help with a game

    I got this Error everytime the scene is reseted. I have no clue where mistake is made. Please help!
    TypeError: Error #1010: A term is undefined and has no properties.
        at golfer_fla::MainTimeline/resetScene()
        at golfer_fla::MainTimeline/golfer_fla::frame1()
    TypeError: Error #1010: A term is undefined and has no properties.
        at golfer_fla::MainTimeline/resetScene()
        at golfer_fla::MainTimeline/countDown()
        at flash.utils::Timer/flash.utils:Timer::_timerDispatch()
        at flash.utils::Timer/flash.utils:Timer::tick()
    If that helps I could send my game by mail so someone could check the error which constantly pop out when the golfer hit the ball, ball stops and the scene resets.
    Here is the code:
    //Variables
    var myHead = new head();
    var myArms = new arms();
    var myBody = new body();
    var myStick = new stick();
    var myGround = new ground();
    var myFlag = new flag();
    var myCapsel = new capsel();
    var grassMask:Number;
    var speedUp:int = 2;
    var speedDown:int = speedUp * 8;
    var checker:int;
    var minPower:int;
    var maxPower:int = 110;
    var strength:Number;
    var capselPower:Number;
    var distance:Number;
    var target:int;
    var tryShot:int = 0;
    var myTimer = new Timer(2000, 1);
    //EventListeners
    stage.addEventListener(KeyboardEvent.KEY_DOWN, onDown);
    stage.addEventListener(KeyboardEvent.KEY_UP, onUp);
    stage.addEventListener(Event.ENTER_FRAME, hit);
    myTimer.addEventListener(TimerEvent.TIMER, countDown);
    //Functions
    function resetScene():void {   
        addChild(myBody);
        addChild(myArms);
        addChild(myHead);
        addChild(myStick);
        addChild(myGround);
        addChild(myFlag);
        addChild(myCapsel);
        grassMask = (320 + Math.random()*260);
        myBody.x = 70;
        myBody.y = 296;
        myArms.x = 68;
        myArms.y = 276;
        myArms.rotation = 0;
        myHead.x = 70;
        myHead.y = 215;   
        myStick.x = 68;
        myStick.y = 276;   
        myStick.rotation = 0;
        myCapsel.x = 90;
        myCapsel.y = 331;
        myGround.x = 0;
        myGround.y = 375;
        myGround.grassMask.x = grassMask - 610;
        myFlag.x = grassMask;
        myFlag.y = 375;
        checker = 0;
        minPower = 0;
        target = 0;
        tryShot ++;
        myCapsel.capselFall.gotoAndStop(1);
        myMessage.text = "Press any key!";
    resetScene();
    function invisibleCapsels():void {   
        a1.visible = false;
        a2.visible = false;
        a3.visible = false;
        a4.visible = false;
        a5.visible = false;
        a6.visible = false;
        a1.gotoAndStop(1);
        a2.gotoAndStop(1);
        a3.gotoAndStop(1);
        a4.gotoAndStop(1);
        a5.gotoAndStop(1);
        a6.gotoAndStop(1);
    invisibleCapsels();
    function onDown(e:KeyboardEvent):void {
        checker = 1;
        minPower = -20;
    function onUp(e:KeyboardEvent):void {
        checker = 0;
        capselPower = (myCapsel.x + myStick.rotation) * 3.2;
    function hit(e:Event):void {
        if(tryShot < 7) {
            if((checker == 1) && (myStick.rotation < maxPower)) {
                myStick.rotation += speedUp;
                myArms.rotation += speedUp;
                } else {
                    if(myStick.rotation > minPower) {
                        myStick.rotation -= speedDown;
                        myArms.rotation -= speedDown;
                    if(myStick.hitTestObject(myCapsel)) {
                        stage.addEventListener(Event.ENTER_FRAME, shot);
                } else {
                    myMessage.text = "Game Over\nClick to play again";
                    stage.addEventListener(MouseEvent.MOUSE_DOWN, playAgain);
    function playAgain(e:MouseEvent):void {
        resetScene();
        invisibleCapsels();
        tryShot = 1;
        stage.removeEventListener(MouseEvent.MOUSE_DOWN, playAgain);
    function shot(e:Event):void {
        strength = (capselPower - myCapsel.x);
        distance = grassMask - myCapsel.x;
        if((Math.round(distance) <= 10) && (Math.round(distance) >= 3) && (strength <= 65)) {
            if(target == 0) {
                myCapsel.capselFall.play();
                myCapsel.rotation = 0;
                target = 1;
                this["a" + tryShot].visible = true;
                myMessage.text = "Cooool!";
                myTimer.start();
            } else {
                if(strength > 5) {
                    myCapsel.x += strength / 30;
                    myCapsel.rotation += strength / 4;
                    } else {
                        this["a" + tryShot].visible = true;
                        this["a" + tryShot].gotoAndStop(2);
                        myMessage.text = "Bad Luck!";
                        myTimer.start();
    function countDown(e:TimerEvent):void {
        resetScene();
        stage.removeEventListener(Event.ENTER_FRAME, shot);

    Try adding the following two lines before line 59:
    trace(myCapsel);
    trace(myCapsel.capselFall);
    If one of them traces undefined, it should isolate which object is the problem.  If you describe what is involved with that object.child, then it may help generate an idea of what might be wrong.

  • Help with platform game

    I can't solve this for days already... When the hero object dies, the floorObject do not remove completely, such that one of them remains. And the hero object
    disappears. Thanks for all the help.
    package
              import flash.display.MovieClip;
              import flash.events.KeyboardEvent;
              import flash.events.*;
              import flash.utils.getTimer;
              public class Platform extends MovieClip
                        // movement constants
                        static const gravity:Number = .004;
                        // screen constants
                        static const edgeDistance:Number = 100;
                        // object arrays
                        private var fixedObjects:Array;
                        private var otherObjects:Array;
                        // hero and enemies
                        private var hero:Object;
                        private var enemies:Array;
                        // game state
                        private var playerObjects:Array;
                        private var gameScore:int;
                        private var gameMode:String = "start";
                        private var playerLives:int;
                        private var lastTime:Number = 0;
                        private var currentX:int = 0;
                        public function startPlatformGame()
                                  // constructor code
                                  gameMode = "play";
                        public function startGameLevel()
                                  createHero();
                                  addEnemies();
                                  // examine level and note all objects
                                  examineLevel();
                                  // add listeners
                                  this.addEventListener(Event.ENTER_FRAME,gameLoop);
                                  stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction);
                                  stage.addEventListener(KeyboardEvent.KEY_UP,keyUpFunction);
                                  // set game state
                                  gameMode = "play";
                        public function createHero()
                                  hero = new Object();
                                  hero.mc = gamelevel.hero;
                                  hero.dx = 0.0;
                                  hero.dy = 0.0;
                                  hero.inAir = false;
                                  hero.direction = 1;
                                  hero.animstate = "stand";
                                  hero.walkAnimation = new Array(2,3,4,5,6,7,8);
                                  hero.animstep = 0;
                                  hero.jump = false;
                                  hero.moveLeft = false;
                                  hero.moveRight = true;
                                  hero.jumpSpeed = .8;
                                  hero.walkSpeed = .15;
                                  hero.width = 30.0;
                                  hero.height = 40.0;
                                  hero.startx = hero.mc.x;
                                  hero.starty = hero.mc.y;
                        public function addEnemies() {
                                  enemies = new Array();
                                  var i:int = 1;
                                  while (true) {
                                            if (gamelevel["enemy"+i] == null) break;
                                            var enemy = new Object();
                                            enemy.mc = gamelevel["enemy"+i];
                                            enemy.dx = 0.0;
                                            enemy.dy = 0.0;
                                            enemy.inAir = false;
                                            enemy.direction = 1;
                                            enemy.animstate = "stand"
                                            enemy.walkAnimation = new Array(2,3,4,5);
                                            enemy.animstep = 0;
                                            enemy.jump = false;
                                            enemy.moveRight = true;
                                            enemy.moveLeft = false;
                                            enemy.jumpSpeed = 1.0;
                                            enemy.walkSpeed = .08;
                                            enemy.width = 30.0;
                                            enemy.height = 30.0;
                                            enemies.push(enemy);
                                            i++;
                        public function examineLevel()
                                  fixedObjects = new Array();
                                  otherObjects = new Array();
                                  for (var i:int=0; i<this.gamelevel.numChildren; i++)
                                            var mc = this.gamelevel.getChildAt(i);
                                            // add floors and walls to fixedObjects
                                            if (mc is Floor)
                                                      var floorObject:Object = new Object();
                                                      floorObject.mc = mc;
                                                      floorObject.leftside = mc.x;
                                                      floorObject.rightside = mc.x + mc.width;
                                                      floorObject.topside = mc.y;
                                                      floorObject.bottomside = mc.y + mc.height;
                                                      fixedObjects.push(floorObject);
                                            else if ((mc is Treasure) )
                                                      otherObjects.push(mc);
                                  fixedObjects.sortOn("leftside" , Array.NUMERIC );
                                  for each (floorObject in fixedObjects)
                                            trace(floorObject.leftside);
                        // add treasure, key and door to otherOjects;
                        public function keyDownFunction(event:KeyboardEvent)
                                  if (gameMode != "play")
                                            return;
                                  }// don't move until in play mode
                                  if (event.keyCode == 37)
                                            hero.moveLeft = true;
                                  else if (event.keyCode == 39)
                                            hero.moveRight = true;
                                  else if (event.keyCode == 32)
                                            if (! hero.inAir)
                                                      hero.jump = true;
                        public function keyUpFunction(event:KeyboardEvent)
                                  if (event.keyCode == 37)
                                            hero.moveLeft = false;
                                  else if (event.keyCode == 39)
                                            hero.moveRight = false;
                        public function gameLoop(event:Event)
                                  // get time differentce
                                  if (lastTime == 0)
                                            lastTime = getTimer();
                                  var timeDiff:int = getTimer() - lastTime;
                                  lastTime +=  timeDiff;
                                  // only perform tasks if in play mode
                                  if (gameMode == "play")
                                            moveCharacter(hero,timeDiff);
                                            checkCollisions();
                                            scrollWithHero();
                                            death();
                        public function moveCharacter(char:Object,timeDiff:Number)
                                  if (timeDiff < 1)
                                            return;
                                  // assume character pulled down by gravity
                                  var verticalChange:Number = char.dy * timeDiff + timeDiff * gravity;
                                  if (verticalChange > 15.0)
                                            verticalChange = 15.0;
                                  char.dy +=  timeDiff * gravity;
                                  // react to changes from key presses
                                  var horizontalChange = 0;
                                  var newAnimState:String = "stand";
                                  var newDirection:int = char.direction;
                                  if (char.moveLeft)
                                            // walk left
                                            horizontalChange =  -  char.walkSpeed * timeDiff;
                                            newAnimState = "walk";
                                            newDirection = -1;
                                  else if (char.moveRight)
                                            // walk right
                                            horizontalChange = char.walkSpeed * timeDiff;
                                            newAnimState = "walk";
                                            newDirection = 1;
                                  if (char.jump)
                                            // start jump
                                            char.jump = false;
                                            char.dy =  -  char.jumpSpeed;
                                            verticalChange =  -  char.jumpSpeed;
                                            newAnimState = "jump";
                                  // assume no wall hit, and hanging in air
                                  char.hitWallRight = false;
                                  char.hitWallLeft = false;
                                  char.inAir = true;
                                  // find new vertical position
                                  var newY:Number = char.mc.y + verticalChange;
                                  // loop through all fixed objects to see if character has landed
                                  for (var i:int=0; i<fixedObjects.length; i++)
                                            if ((char.mc.x+char.width/2 > fixedObjects[i].leftside) && (char.mc.x-char.width/2 < fixedObjects[i].rightside))
                                                      if ((char.mc.y <= fixedObjects[i].topside) && (newY > fixedObjects[i].topside))
                                                                newY = fixedObjects[i].topside;
                                                                char.dy = 0;
                                                                char.inAir = false;
                                                                break;
                                  // find new horizontal position
                                  var newX:Number = char.mc.x + horizontalChange;
                                  // loop through all objects to see if character has bumped into a wall
                                  for (i=0; i<fixedObjects.length; i++)
                                            if ((newY > fixedObjects[i].topside) && (newY-char.height < fixedObjects[i].bottomside))
                                                      if ((char.mc.x-char.width/2 >= fixedObjects[i].rightside) && (newX-char.width/2 <= fixedObjects[i].rightside))
                                                                newX = fixedObjects[i].rightside + char.width / 2;
                                                                char.hitWallLeft = true;
                                                                break;
                                                      if ((char.mc.x+char.width/2 <= fixedObjects[i].leftside) && (newX+char.width/2 >= fixedObjects[i].leftside))
                                                                newX = fixedObjects[i].leftside - char.width / 2;
                                                                char.hitWallRight = true;
                                                                break;
                                  // set position of character
                                  char.mc.x = newX;
                                  char.mc.y = newY;
                                  // set animation state
                                  if (char.inAir)
                                            newAnimState = "jump";
                                  char.animstate = newAnimState;
                                  // move along walk cycle
                                  if (char.animstate == "walk")
                                            char.animstep +=  timeDiff / 60;
                                            if (char.animstep > char.walkAnimation.length)
                                                      char.animstep = 0;
                                            char.mc.gotoAndStop(char.walkAnimation[Math.floor(char.animstep)]);
                                            // not walking, show stand or jump state
                                  else
                                            char.mc.gotoAndStop(char.animstate);
                                  // changed directions
                                  if (newDirection != char.direction)
                                            char.direction = newDirection;
                                            char.mc.scaleX = char.direction;
                        public function checkCollisions()
                                  for (var i = otherObjects.length-1; i >= 0; i--)
                                            if (hero.mc.hitTestObject(otherObjects[i]))
                                                      getObject(i);
                                  for (var j:int = enemies.length-1; j>=0; j--)
                                            if (hero.mc.hitTestObject(enemies[j].mc))
                                                      currentX = hero.mc.x;
                                                      gameComplete();
                        public function scrollWithHero()
                                  var stagePosition:Number = gamelevel.x + hero.mc.x;
                                  var rightEdge:Number = stage.stageWidth - edgeDistance;
                                  var leftEdge:Number = edgeDistance;
                                  if (stagePosition > rightEdge)
                                            gamelevel.x -= (stagePosition-rightEdge);
                                            if (gamelevel.x < -(gamelevel.width-stage.stageWidth))
                                                      gamelevel.x = -(gamelevel.width-stage.stageWidth);
                                  if (stagePosition < leftEdge)
                                            gamelevel.x += (leftEdge-stagePosition);
                                            if (gamelevel.x > 0)
                                                      gamelevel.x = 0;
                        public function getObject(objectNum:int)
                                  if (otherObjects[objectNum] is Treasure)
                                            gamelevel.removeChild(otherObjects[objectNum]);
                                            otherObjects.splice(objectNum,1);
                        public function death()
                                  if (hero.mc.y > 300)
                                            currentX = gamelevel.hero.x;
                                            trace(currentX);
                                            gameComplete();
                        public function gameComplete()
                                  gameMode = "dead";
                                  var dialog:Dialog = new Dialog();
                                  dialog.x = 175;
                                  dialog.y = 100;
                                  addChild(dialog);
                                  dialog.message.text = "Gameover";
                        public function clickDialogButton(event:MouseEvent)
                                  removeChild(MovieClip(event.currentTarget.parent));
                                  // new life, restart, or go to next level
                                  if (gameMode == "dead")
                                            // reset hero
                                            hero.mc.x = currentX;
                                            hero.mc.y = 0;
                                            trace("dead");
                                            setReplay();
                                            gameMode = "play";
                                  // give stage back the keyboard focus
                                  stage.focus = stage;
                        public function setReplay()
                                  for (var i:int = fixedObjects.length-1; i>-1; i--)
                                            if (fixedObjects[i].leftside < currentX)
                                                      this.gamelevel.removeChildAt(fixedObjects[i]);
                                                      fixedObjects.splice(i,1);
                                                      trace("Splice?");
                                  for each (var floorObject in fixedObjects){
                                            trace(floorObject.leftside);
                        public function cleanUp()
                                  removeChild(gamelevel);
                                  this.removeEventListener(Event.ENTER_FRAME,gameLoop);
                                  stage.removeEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction);
                                  stage.removeEventListener(KeyboardEvent.KEY_UP,keyUpFunction);

    Ok, I fiured it all out, the other way you mentioned. Just opened up the character MC, and named 2 frames. One LEFT and one RIGHT. Then I added a few simple lines of code, and turned out with this:
    if (Key.isDown(Key.RIGHT)) {
    _x += speed;
    this.gotoAndStop("right");
    if (Key.isDown(Key.LEFT)) {
    _x -= speed;
    this.gotoAndStop("left");
    Thanks for helping!!!

  • Help With Online Game (Walking Talking)...

    Hello, I just want to make like something like a game where you conrol a box, and can write messages to other people...
    But the thing is that i am absolutely new in JAVA i don't know anything in it (totally)
    So i would like to get some information in working with it... and things like that ^.^
    P.S. I worked with GameMaker but I don't think that it will help me :|

    I Don't know but it' didn't work maybe cause i am using vista???
    when it didn't work i made a bat file and wrote there: javac HelloWorldApp.java
    i think it did something but new file didn't appear anywhere. maybe it shuld appear in any other folder or something?
    EDIT: I thought that vista doesn't let me to make new files in C disk so i copied the *.java file to the desktop and when i cmd i tried to javac it, the compiler started writing:
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    C:\Users\TDEsws\Desktop>javac HelloWorldApp.java
    by his self... it didn't stop waited about 30seconds...
    Edited by: TDEsws on Nov 5, 2008 5:37 AM

  • Need help with a game..

    I was wondering if anyone can help me out with a little problem.
    Little info about the code:
    I am creating a game, where a player has to answer a set of math questions with answers that are only
    in whole numbers. If you look at method: showQuestion() I have used a for loop show the question on a
    label. There are no compile errors. So i assume, the problem is related to exception handling or something
    the problem:
    if you look at the last method actionPerformed(ActionEvent e), in there when you click the nextQ button
    i get paragraphs exception errors, or so i think there exceptions, im new to programming so tend to get
    jumbled now and again.
    extra info:
    There is another class called Questions, too long to paste here, but in that class i have defined
    the questions and corresponding answers in arrays as such:
    String[] Questions = new String[50];
    int [] Answers = new int[50]
         Question[0] = "What is 2 x 8? ";
         Answer[0] = 16;
         etc etc for the entire 50 questions. so you get my idea here.
    again if you look at showQuestion() whatever question is displayed its answer is worked out using the
    index i.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Game extends Questions implements ActionListener
        /** Global Variables Declared */
        /** Global Variables for Components in GUI */
        /** Constructor initialise game */
        public void showQuestion()
            int i;
                for(i=0; i<Questions.length; i++)
                        showQuestion.setText(Questions);
    Answer = Answers[i];
    public void makeFrame()
    // Creates Frame
    // Labels
    // TextBox for user input
    // Buttons
    // Sets Frame size
    // Listen to events (addActionListener)
    // Container ContentPane and add components to it
    // Frame Close and Visibility properties
    public void actionPerformed(ActionEvent e)
    // if QuitGame button is pressed do the following...
    if(e.getSource()==NextQ) {
    showQuestion.setText("Question 1: " + Questions[i]);
    else {            

    Dude are all 50 questions and answers in the array occupied?
    * array.length is the capacity of the array, not "how many are occupied".
    2. You're typically better of using an ArrayList instead of an array, because ArrayList's are resized dynamically.
    3. don't use "paralell" arrays... instead create a class which keeps your shite together, and then create a collection of them... something like...
    class QuestionTO { // to stands for Tranfer Object
      private final String question;
      private final String answer;
      public QuestionTO(String question, String answer) {
        this.question = question;
        this.answer = answer;
      public String getQuestion() { return this.question; }
      public String getAnswer() { return this.answer; }
      public String toString("<Question question=\""+getQuestion()+"\" answer=\""+getAnswer()+"\" />");
    class Questionarre {
      List<QuestionTO> questions = new ArrayList<QuestionTO>();
      public void print(PrintStream out) {
        for (QuestionTO question : questions) {
          out.println(question.toString()));
    }Hope that helps some... even if it's "a bit beyond" you at the moment... doing stuff "the proper way" is most often easier, coz the super-geeks have done most of the heavy lifting for you.
    Keith.

  • I need help with a game called "sticks"...go figure(!)

    Help! I have just started using Java, and already I need to create a simple game, but I am having problems already.
    The game is designed for 2 player with the one human player and the computer. Players alternatively take sticks from a pile, the player taking the last stick loses.
    Any Ideas?
    Many Thanks...
    Dr. K

    If I take a stick and then smash the computer to pieces with it, do I win???

  • Help with transfering games

    I have tried to download games but it keeps saying I have to go to the store and authorize computer..I have already authorized it before and when I went back to the store to find the authorized computer selection I could not find it.. Help please

    As noted by chris above the games are not compatible with the ipod nano only the larger ipod video. THe games on th eitunes music store in fact make this warning known jsut below the game description
    "...THese games are CANNOT be played in itunes, NOR are they COMPATIBLE with other IPOD MODELS." Nor can they be playyed in itunes.
    With the emphasis given of course. I dont believe you can get a refund because the system requirements are clearly noted. On another note the ipod nano is Not able to play ANy video content including podcasts. IF you wish for either of these features youll need the ipod video.
    GFF:)

  • Help with ipod games!!!

    i cant get games to go on my ipod :s
    do you just download them and the are they supposed to go on your ipod when you plug it on because if that is whats supposed to happen then mine does not do that and i really dont understand how to get them on? it is an ipod nano i am tryin to get the game on? please help x

    As noted by chris above the games are not compatible with the ipod nano only the larger ipod video. THe games on th eitunes music store in fact make this warning known jsut below the game description
    "...THese games are CANNOT be played in itunes, NOR are they COMPATIBLE with other IPOD MODELS." Nor can they be playyed in itunes.
    With the emphasis given of course. I dont believe you can get a refund because the system requirements are clearly noted. On another note the ipod nano is Not able to play ANy video content including podcasts. IF you wish for either of these features youll need the ipod video.
    GFF:)

  • Help with lingo game

    Hey guys,
    i'm making an adventure style game using lingo. But i can't
    figure out how to make my sprite transport from room to room. I'd
    like the character to go up to the door either push space or click
    on the door (maybe a notice comes up?) then appear in another room.
    I've looked for tutorials on this kind of thing but have been
    unsuccessful. Can anyone help me? I learn better from one to one
    and would really appreciate anyone with some spare time. I have a
    private email address is this is better.
    Thanx so much guys. x

    it's a 2d game. I've figured out the marker thing now and i'm
    happy with clicking on the door rather than using space bar to go
    from room to room. I wonder if you could help me with a new problem
    though? lol, here it is;
    Hey guys, can anyone help me?
    Here is some script that makes my character obviously move
    and detects walls. I would like to modify the script so that when
    my character hits the right keydown, the sprite changes to cast
    member "right". I have tried and so far all i have done is succeed
    in making the cast member change but this then deactivates the
    walls. Any ideas??
    on exitFrame me
    if keyPressed(123) then
    move(me,-5,0)
    end if
    if keyPressed(124) then
    move(me,5,0)
    end if
    if keyPressed(125) then
    move(me,0,5)
    end if
    if keyPressed(126) then
    move(me,0,-5)
    end if
    end
    on move me, dx, dy
    oldRect = sprite(me.spritenum).rect
    newRect = oldRect + rect(dx,dy,dx,dy)
    hitWall = FALSE
    repeat with i = 2 to 30
    if sendSprite(i,#hitWall,newRect) then
    hitWall = TRUE
    exit repeat
    end if
    end repeat
    if not hitWall then
    sprite(me.spriteNum).loc = sprite(me.spriteNum).loc +
    point(dx,dy)
    end if
    end
    Many thanks.

  • Please help with Boggle game

    The Input
    The input file is exactly as in WordSearch.java and in fact, you can reuse almost the entire program, especially the routines to read the word and puzzle files. In order to limit the amount of output words that are less than nine characters are not to be considered matches.
    Strategy
    First, provide a Position class to store a row and column as a pair, and provide a constructor, toString, and equals (hashCode would also be good to have, but is not needed). Make sure Position is an immutable type.
    Next, change solvePuzzle to solveBoggle as follows:
         * Routine to solve the Boggle game.
         * @return a Map containing the strings as keys, and the positions used
         *     to form the string (as a List) as values
        public Map solveBoggle( )
            Map results = new HashMap( );
            List path = new ArrayList( );
            for( int r = 0; r < rows; r++ )
                for( int c = 0; c < columns; c++ )
                    solve( new Position( r, c ), "", paths, results );
            return results;
        }Observe that solveBoggle calls the routine solve for each position in the grid. solve is recursive, and implementing it is virtually the entire assignment. After you implement solve you should have a routine that can print out, in a nice form, the Map returned by solveBoggle.
    The specification for the recursive solve routine is:
         * Hidden recursive routine.
         * @param thisPos the current position
         * @param charSequence the characters in the potential matching string thusfar
         * @param path the List of positions used to form the potential matching string thusfar
         * @param results the Map that contains the strings that have been found as keys
         *       and the positions used to form the string (as a List) as values.
        private void solve( Position thisPos, String charSequence, List path, Map results )
            /* Less than one page of code will do it. */
        }In implementing solve you will want to do the following:
    Attach the character at thisPos to charSequence.
    If the resulting current string is not a prefix of any word in the dictionary, you can return.
    Otherwise, you will want to update the path variable, and look for some matches.
    If the current string is a word in the dictionary you want to update the map.
    In any event, you want to recursively call solve with appropriate parameters, on all adjacent positions, skipping those that have already been used in the current string, and being careful not to wander off the end of the board.
    Don't forget to update the path variable when you return from solve.
    Copying and Cloning
    As much as possible, you should avoid making copies of variables. In particular, the last two parameters to solve (the List and Map are to be the same object for each unique invocation of solveBoggole. YOU MAY NOT MOVE THEM TO BE CLASS VARIABLES. However, what this means is that when you put a String as a key and a List as a value into the Map, you will need at that point to make a copy of the List, since otherwise the Map would simply be storing lots of references to the same single list (which would be empty at the end of the program). You can use any of the List (subclasses) constructors to create a List from another List.
    This is the puzzle file:
    fozepdkdnqlhfejdzksccfykdxnlorwvfwavbmyqclxjrgntqhvuowgrtufhnbdt
    zfqatqryeqhxxuqpdmmsksjdooncssvrznssflsjbahawxsalesvwdblsqpkimdj
    zxdeiwqmwxouwgukkmfjqiwkynwizztyxxehtuvrtklqsgaduhomsmyszwbywwyv
    teeozafumtmebojvwxkqliimhlmfikabpgsqizkuszztnirlibbtlkgsvuzdfbhw
    iboqaaltzkmnsdycgawukeohyonfpwdxxrqxubqtnfghkhkrhintobcorpwhlzgi
    tyinbyiofryqykjhswcizgwrwsajuiuphceicmzifxyfjhodfqlexhxvcxgyganp
    erxhfyrnxpsgyhjdzuhyefviecgkcvbhozqvzhixyddwkpzllikrpfzuhhgmeivu
    jlqiuafsdlopapbnxlfnsehaopmsxjpgufpofwglhwajlbxkmcxfighwwvrtegca
    nroupwfxugifhfpwjpdsxmqthjpnrrngkdbzbgyvojcwqtuakzuilmbuyshplwwv
    bzxcfxzugdszwozhnvryhushnbxyxvwyuvcbsbxbgpccfblsyeshzmpmnommjimf
    fogarebxvdcbgpvguonvachqsvebgrglhplbvoaqtetzuphqdvlfzuxsrcvxvele
    twfolgggmaigppyumlbmhzgzdbwyfhcagiqtqxzcxhlmxlilxjxeiddlhclolopr
    yfmqemubvhputxgsjdwtjchsgsirixlifxyljvnhccbxchplnogysnsygapqaazh
    azsluhszmwwofobuchuuxmsdpjtpmuyouqzoaupmqmavcdqemkajzuoqfkftefhy
    xhpxbejrslouogadtcmsydienpxrwfstojrppaiioyecfhhylwskzcomtnfpuzii
    izzycjiqiounxcnjaftzjjncyurtuzdebfedomvybrnavajvhewqnjsogljclmgo
    tltizoicfwdbwmygrvwggrumcdopsxdliwvjmemuapxydvewsddzwznyfcozztmj
    siseogaqvxozvvxnaamwcawjemkfgwqaekesrfioeznzwnnwpburdqchdmoljelp
    priiyswdtmepztnovhiaakkfzyqifdxwuhetcayvmcnlwcctkkvmufrtejdlmdhi
    klbonbmagzncbpxnbszwasrgbxrpayymlbbydnyjoonpfmfhgedgzwmatdsvdqio
    rjnuwnfkdsbjegqlnvrmrgonlgiryqfqbumzkslnknwrvmckjvwddnqpvagutnkw
    kwwuqhjbwguuuyegtdjzsbqnbyhwnttxsrtiadlxlfthdxnzcwauxqiborzbnubf
    lupmzblkieumdhnigncdfmgtgiwtcxaoupctqngbtanyhcinrntwzbphjnconceh
    ugckvinqiaqsezhvmcrneivpyxdlcjswpuimfwcpythfuragtutzeqrcqupsgjqv
    gyilwmavhkabbchuwdudtlhlhxdngtlmuvxqhanrkpslscfqfbtaodmyarlinyvh
    tuzdupugeorwqzpvakyrnkpnbcwobtxwnzbkoxqsmkrcjgalqyceittlwrczkzxa
    yzmmwehioynzenlwlpatjwghnigaidcieoxdueljeakknvgyljtwhaduklwuqydv
    ocylglummewbceapnvnuxqridpctqhoejorrcldqsbrwgtnvraqoqjytydookdvw
    tmnxatnuuhsacfwtfokvzkqxpeoajlyfxlczgstbbnddszzxpluoxkmnrcpcnnhm
    ammhehifvlknnjlcwfrusfhljwnwjxiljwspeaubogobqbfojyiddpqondkycvkn
    recxfyyvfpyxqdlbcwehnuwbaibcdlqxquuxttuyisxyxicbggludjvfrwjxkbuc
    wobrhvprposmyuqfcbzhkumdswaezwivljmugdmxrekqycxadwipswsmsvrsrzpc
    lexrhlpbpbtpfqpimzxgwrsqmjkelciyghrpsiqhjlwqboyppxxnrqgdbsjousmc
    besumkdywaozqprfmovfgbjituwqolsqpmkbxnzvpquffnnteizklkueetutepjv
    bvwykytaqqhvfwojgnurxqyejuxpjiklfjlpjhrzzbuexkqeamvzctdoocdzmqmr
    bajkjajibfozpefrqcrvywjobonngafhcorlqcvshjtzqaqicjdagmohdewjgbti
    rkvknqewbxvrzoabxdefsuoxalggmzqgmlsbbwxfvvwulyxicbqwyetypbhedxmp
    jeqmaprvmqrxooissyoqchqslxyovkdgovuomolzecyssglmgbejjvduubiplnxb
    kspwicxmgyeyernltrwembahckypxyqhshfalfmrdsrhmeuhwslkvltzxuouugdm
    pkoapcrsulcipypntcaoptompcijlnxaylbnnuikfksxkkmdmmseigqzkbjvogym
    sbchvkrdwkcgwokkdconkhmuixswgqlarphobztxlvdjmptptiedrsazquxykkyd
    zhtainzvkfewuynqirvzkvacpzcbkagljcmsrnpbsuypulfefafpyhtpgvtqxbcg
    dqaudswyownkjsoouvfscykkvdbsefbkxdgcveajantkhjacegwiggtclwusdxcc
    bkeyphirwddepegvkeeslzuyxrqcouerfkquranofruuvaqhgwzrxuquniwbdcti
    mjeglrwqiqlfsdoyzoswkksxsoyvqtfeejkpdiinyvtsyhtxxlvhvngpdhlvaqbh
    coyhwguxbppbzkawvvgskmipvtmylofpcfwymtxpiprhzrgvpopbaxrysdwgrdvv
    iuwwntmviffiwlfnzwpbugbolxwfaualoyhdsvycafmzsrmtqbxkjyavyxcarclh
    btkvokxrskqkdcgtgdfpbimbfocytnhwitrzdqqvagigkobqthiwrwywlawgnfcy
    yvxdlnbmvjufzvyseiovemtrorxewbcwwzaiobwjmsolnoduwtpdglwucuybxcxu
    bzepaaamspxhfcdewthegdaizblxdlthkzwlbxzvoxcvbgzxbgdhmerlhfkkqfra
    eqnfpnadmfynlynogqxswqgdvsqlyhocxbkmokrapsqcsdsyvptugzzdtpprxfww
    gglxsezkwpoouhpqyikgjjkebbwyguwoajluolekcvbxeqpcabllmxpnynnghkuj
    tgejtkwvfxujpjmrkzexwtkujycqkwafcgpxqlvwkpfzztsjswgqrtmatotdltkp
    bznrminyxvxyopijnqzfjmfcayhntsdutsoicdgzygapxiylazqknxooyybrsgol
    yevahecgkcvjmvumwmykkpyinbbfkrsivqlfupletinffktbwslijlswpwdzpxjn
    nwshlfnepdlupfxlzjwiwognkloaianywhhkmvobaaxphucgfyqcnwrzhgbrgqpe
    xxolufmuhjjoelwlmmnbiharneivwyzuvqfrvulcfwsjjovvakwktzbidjdbjfvg
    vdxszkwegoqqenlexkqtjrbocfpmmnujssbrezvlnlbryoxyanrjguzibrwnetyy
    nbprakcpyfgywfwwupiakjllajbgczerbtjbgnrgtzerhdnbuxeehrshatqfuuwv
    qhzwvqeorihanueiuimbzgkbbagwxfrnmqjhinxcxeclbgtvqhyrqitrlbnigfvv
    xgeivcmuiohlxagpkgharcrcdhmmojhlrlvophiyyqjvssmeatervyvbfhntswgj
    jcxzlizjykgsetxfmbykbulibyduwkffodgzlhjlupdakahxeghfasqdstzodfvt
    kctxleifvnggonfutobvgrzalyoqfjkrnfozlyegmmocctwvhztprspesfuargrg
    lgfwemfsatucpsywurollfrflnfeuxkhfsgleleegahvvhupakanptsagaeaxrke
    the dictionary file is too big to post but it is something like this:
    a
    aah
    aardvark
    aardvarks
    aardwolf
    aardwolves
    aba
    abaca
    abaci
    aback
    abacterial
    abacus
    abacuses
    abaft
    abalone
    abalones
    abandon
    abandoned
    abandoning
    abandonment
    abandons
    abase
    abased
    abasement
    abasements
    abases
    abash
    abashed
    abashes
    abashing
    abashment
    abashments
    abasing
    abatable
    abate
    abated
    abatement
    abater
    abaters
    abates
    abating
    abatis
    abatises
    abattoir
    abattoirs
    abaxial
    abbacies
    abbacy
    abbe
    abbess
    abbey
    abbot
    abbots
    abbreviate
    abbreviated
    abbreviates
    abbreviating
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.InputStreamReader;
    import java.io.IOException;
    import java.util.Arrays;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    // WordSearch class interface: solve word search puzzle
    // CONSTRUCTION: with no initializer
    // ******************PUBLIC OPERATIONS******************
    // int solvePuzzle( )   --> Print all words found in the
    //                          puzzle; return number of matches
    public class WordSearch
         * Constructor for WordSearch class.
         * Prompts for and reads puzzle and dictionary files.
        public WordSearch( ) throws IOException
            puzzleStream = openFile( "Enter puzzle file" );
            wordStream   = openFile( "Enter dictionary name" );
            System.out.println( "Reading files..." );
            readPuzzle( );
            readWords( );
         * Routine to solve the word search puzzle.
         * Performs checks in all eight directions.
         * @return number of matches
        public int solvePuzzle( )
            int matches = 0;
            for( int r = 0; r < rows; r++ )
                for( int c = 0; c < columns; c++ )
                    for( int rd = -1; rd <= 1; rd++ )
                        for( int cd = -1; cd <= 1; cd++ )
                            if( rd != 0 || cd != 0 )
                                matches += solveDirection( r, c, rd, cd );
            return matches;
         * Search the grid from a starting point and direction.
         * @return number of matches
        private int solveDirection( int baseRow, int baseCol, int rowDelta, int colDelta )
            String charSequence = "";
            int numMatches = 0;
            int searchResult;
            charSequence += theBoard[ baseRow ][ baseCol ];
            for( int i = baseRow + rowDelta, j = baseCol + colDelta;
                     i >= 0 && j >= 0 && i < rows && j < columns;
                     i += rowDelta, j += colDelta )
                charSequence += theBoard[ i ][ j ];
                searchResult = prefixSearch( theWords, charSequence );
                if( searchResult == theWords.length )
                    break;
                if( !((String)theWords[ searchResult ]).startsWith( charSequence ) )
                    break;
                if( theWords[ searchResult ].equals( charSequence ) )
                    numMatches++;
                    System.out.println( "Found " + charSequence + " at " +
                                        baseRow + " " + baseCol + " to " +
                                        i + " " + j );
            return numMatches;
         * Performs the binary search for word search.
         * @param a the sorted array of strings.
         * @param x the string to search for.
         * @return last position examined;
         *     this position either matches x, or x is
         *     a prefix of the mismatch, or there is no
         *     word for which x is a prefix.
        private static int prefixSearch( Object [ ] a, String x )
            int idx = Arrays.binarySearch( a, x );
            if( idx < 0 )
                return -idx - 1;
            else
                return idx;
         * Print a prompt and open a file.
         * Retry until open is successful.
         * Program exits if end of file is hit.
        private BufferedReader openFile( String message )
            String fileName = "";
            FileReader theFile;
            BufferedReader fileIn = null;
            do
                System.out.println( message + ": " );
                try
                    fileName = in.readLine( );
                    if( fileName == null )
                         System.exit( 0 );
                    theFile = new FileReader( fileName );
                    fileIn  = new BufferedReader( theFile );
                catch( IOException e )
                  { System.err.println( "Cannot open " + fileName ); }
            } while( fileIn == null );
            System.out.println( "Opened " + fileName );
            return fileIn;
         * Routine to read the grid.
         * Checks to ensure that the grid is rectangular.
         * Checks to make sure that capacity is not exceeded is omitted.
        private void readPuzzle( ) throws IOException
            String oneLine;
            List puzzleLines = new ArrayList( );
            if( ( oneLine = puzzleStream.readLine( ) ) == null )
                throw new IOException( "No lines in puzzle file" );
            columns = oneLine.length( );
            puzzleLines.add( oneLine );
            while( ( oneLine = puzzleStream.readLine( ) ) != null )
                if( oneLine.length( ) != columns )
                    System.err.println( "Puzzle is not rectangular; skipping row" );
                else
                    puzzleLines.add( oneLine );
            rows = puzzleLines.size( );
            theBoard = new char[ rows ][ columns ];
            Iterator itr = puzzleLines.iterator( );
            for( int r = 0; r < rows; r++ )
                String theLine = (String) itr.next( );
                theBoard[ r ] = theLine.toCharArray( );
         * Routine to read the dictionary.
         * Error message is printed if dictionary is not sorted.
        private void readWords( ) throws IOException
            List words = new ArrayList( );
            String lastWord = null;
            String thisWord;
            while( ( thisWord = wordStream.readLine( ) ) != null )
                if( lastWord != null && thisWord.compareTo( lastWord ) < 0 )
                    System.err.println( "Dictionary is not sorted... skipping" );
                    continue;
                words.add( thisWord );
                lastWord = thisWord;
            theWords = words.toArray( );
          // Cheap main
        public static void main( String [ ] args )
            WordSearch p = null;
            try
                p = new WordSearch( );
            catch( IOException e )
                System.out.println( "IO Error: " );
                e.printStackTrace( );
                return;
            System.out.println( "Solving..." );
            p.solvePuzzle( );
        private int rows;
        private int columns;
        private char [ ][ ] theBoard;
        private Object [ ] theWords;
        private BufferedReader puzzleStream;
        private BufferedReader wordStream;
        private BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) );
    }Thank you in advance

    Ok, I'm stuck. Please somebody. It seems like I'm not moving inside the board. This is what I have done so far:
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.InputStreamReader;
    import java.io.IOException;
    import java.util.Arrays;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;
    import java.util.HashMap;
    public class WordSearch
         * Constructor for WordSearch class.
         * Prompts for and reads puzzle and dictionary files.
        public WordSearch( ) throws IOException
            puzzleStream = openFile( "Enter puzzle file" );
            wordStream   = openFile( "Enter dictionary name" );
            System.out.println( "Reading files..." );
            readPuzzle( );
            readWords( );
           * Private class Position is a class to store a row and a column
           * as a pair.
        private class Position
             int row;
             int column;
                * A constructor from two integers
                * @param r is the row of the position
                * @param c is the column of the position
             Position( int r, int c )
                  row = r;
                  column = c;
                * First accessor
                * @return the row as an int
              public int getRow( )
                   return row;
                * Second accessor
                * @return the column as an int
              public int getColumn( )
                   return column;
                * Position objects are equal if both rows and columns are equal
                 * @return true if both rows and columns are equal; false otherwise
              public boolean equals( Object aPosition )
                   int x = ( (Position) aPosition ).getRow( );
                   int y = ( (Position) aPosition ).getColumn( ); 
                 return ( ( row == x ) && ( column == y ) );
                * Returns a String representation of Position
                   * @return a String with Position as ( x, x )
              public String toString( )
                 return ( "( " + row + ", " + column + " )" );
        } // end of Position
         * Routine to solve the Boggle game.
         * @return a Map containing the strings as keys, and the positions
         * used to form the string (as a List) as values
        public Map solveBoggle( )
            Map results = new HashMap( );
            List path = new ArrayList( );
            boolean[][] marked = new boolean[rows][columns];
            for( int r = 0; r < rows; r++ )
                 for( int c = 0; c < columns; c++ )
                    solve( new Position( r, c ), "", path, results, marked);
            return results;
         * Hidden recursive routine.
         * @param thisPos the current position
         * @param charSequence the characters in the potential matching string thusfar
         * @param path the List of positions used to form the potential matching string thusfar
         * @param results the Map that contains the strings that have been found as keys
         * and the positions used to form the string (as a List) as values.
        private void solve( Position thisPos, String charSequence, List path, Map results,
                  boolean[ ][ ] marked )
             int row = thisPos.getRow( );
             int col = thisPos.getColumn( );
             charSequence += theBoard[ row ][ col ];
            int searchResult = prefixSearch( theWords, charSequence );
            if( searchResult == theWords.length )
                   return;
              if( theWords[ searchResult ].equals( charSequence ) )
                 path.add( thisPos );
                 results.put( charSequence, path );
                 path.clear( );
                 charSequence.replaceAll( charSequence, "" );
                 return;
            if( !( (String)theWords[ searchResult ] ).startsWith( charSequence ) )
                 return;
            else
                 path.add( thisPos );
                 marked[ thisPos.getRow( ) ][ thisPos.getColumn( ) ] = true;     
                   if( ((row-1) >= 0) && ((col-1) >= 0) && !marked[row-1][col-1] )
                        marked[row-1][col-1] = true;
                        solve( new Position(row-1, col-1), charSequence, path, results, marked);
                   if( ((row-1) >= 0) && !marked[row-1][col] )
                        marked[row-1][col] = true;
                        solve( new Position(row-1, col), charSequence, path, results, marked);
                   if( ((row-1) >= 0) && ((col+1) < columns) && !marked[row-1][col+1]  )
                        marked[row-1][col+1] = true;
                        solve( new Position(row-1, col+1), charSequence, path, results, marked);
                   if( ((col-1) >= 0) && !marked[row][col-1]  )
                        marked[row][col-1] = true;
                        solve( new Position(row, col-1), charSequence, path, results, marked);
                   if( ((col+1) < columns) && !marked[row][col+1] )
                        marked[row][col+1] = true;
                        solve( new Position(row, col+1), charSequence, path, results, marked);
                   if( ((row+1) < rows) && ((col-1) >= 0) && !marked[row+1][col-1] )
                        marked[row+1][col-1] = true;
                        solve( new Position(row+1, col-1), charSequence, path, results, marked);
                   if( ((row+1) < rows) && !marked[row+1][col] )
                        marked[row+1][col] = true;
                        solve( new Position(row+1, col), charSequence, path, results, marked);
                   if( ((row+1) < rows) && ((col+1) < columns) && !marked[row+1][col+1] )
                        marked[row+1][col+1] = true;
                        solve( new Position(row+1, col+1), charSequence, path, results, marked);
         * Performs the binary search for word search.
         * @param a the sorted array of strings.
         * @param x the string to search for.
         * @return last position examined;
         *     this position either matches x, or x is
         *     a prefix of the mismatch, or there is no
         *     word for which x is a prefix.
        private static int prefixSearch( Object [ ] a, String x )
            int idx = Arrays.binarySearch( a, x );
            if( idx < 0 )
                return -idx - 1;
            else
                return idx;
         * Print a prompt and open a file.
         * Retry until open is successful.
         * Program exits if end of file is hit.
        private BufferedReader openFile( String message )
            String fileName = "";
            FileReader theFile;
            BufferedReader fileIn = null;
            do
                System.out.println( message + ": " );
                try
                    fileName = in.readLine( );
                    if( fileName == null )
                         System.exit( 0 );
                    theFile = new FileReader( fileName );
                    fileIn  = new BufferedReader( theFile );
                catch( IOException e )
                  { System.err.println( "Cannot open " + fileName ); }
            } while( fileIn == null );
            System.out.println( "Opened " + fileName );
            return fileIn;
         * Routine to read the grid.
         * Checks to ensure that the grid is rectangular.
         * Checks to make sure that capacity is not exceeded is omitted.
        private void readPuzzle( ) throws IOException
            String oneLine;
            List puzzleLines = new ArrayList( );
            if( ( oneLine = puzzleStream.readLine( ) ) == null )
                throw new IOException( "No lines in puzzle file" );
            columns = oneLine.length( );
            puzzleLines.add( oneLine );
            while( ( oneLine = puzzleStream.readLine( ) ) != null )
                if( oneLine.length( ) != columns )
                    System.err.println( "Puzzle is not rectangular; skipping row" );
                else
                    puzzleLines.add( oneLine );
            rows = puzzleLines.size( );
            theBoard = new char[ rows ][ columns ];
            Iterator itr = puzzleLines.iterator( );
            for( int r = 0; r < rows; r++ )
                String theLine = (String) itr.next( );
                theBoard[ r ] = theLine.toCharArray( );
         * Routine to read the dictionary.
         * Error message is printed if dictionary is not sorted.
        private void readWords( ) throws IOException
            List words = new ArrayList( );
            String thisWord;
            while( ( thisWord = wordStream.readLine( ) ) != null )
                words.add( thisWord );          
            theWords = words.toArray( );
            Arrays.sort( theWords );
           * Prints a String representation of the words found and their List of positions.  
           * @Prints a String with the words found and their List of positions.
        public static void printMap( Map wordMap )
             Iterator itr1 = wordMap.entrySet( ).iterator( );
             String str = "";        
            while( itr1.hasNext( ) )
                 String aWord = (String)( (Map.Entry)itr1.next( ) ).getKey( );  
                 str += "Found " + aWord + " at ";
                 Iterator itr2 = ( (List)( ( (Map.Entry)itr1.next( ) ).
                           getValue( ) ) ).iterator( );
                 while( itr2.hasNext( ) )
                      str += (Position)itr2.next( );
                      if( itr2.hasNext( ) )
                           str += ", ";
                      else
                           str += "\n";
             System.out.println( str );
         } // end of printMap
          // Cheap main
        public static void main( String [ ] args )
            WordSearch p = null;
            try
                p = new WordSearch( );
            catch( IOException e )
                System.out.println( "IO Error: " );
                e.printStackTrace( );
                return;
            System.out.println( "Solving..." );
            Map wordMap = p.solveBoggle( );
            p.printMap( wordMap );
        private int rows;
        private int columns;
        private char [ ][ ] theBoard;
        private Object [ ] theWords;
        private BufferedReader puzzleStream;
        private BufferedReader wordStream;
        private BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) );
    }Thanks

  • Help with 'Learning Games

    Hey you all, I have done very little Flash design, but have a request from a client to add a bunch of Flash childrens' learning games to their website.  I have enough experience to add the premade ones, but not develop them from scratch of course.
    There are several sites out there that offer free games, but they always add their website advertisement to the loading area or other areas of the game.
    Does anyone know of a purchasable pack of games for developers that can be inserted into standard site pages relatively easily?   Of course if there is a free pack without ads that would be equally nice 

    As noted by chris above the games are not compatible with the ipod nano only the larger ipod video. THe games on th eitunes music store in fact make this warning known jsut below the game description
    "...THese games are CANNOT be played in itunes, NOR are they COMPATIBLE with other IPOD MODELS." Nor can they be playyed in itunes.
    With the emphasis given of course. I dont believe you can get a refund because the system requirements are clearly noted. On another note the ipod nano is Not able to play ANy video content including podcasts. IF you wish for either of these features youll need the ipod video.
    GFF:)

  • Help with downloading games please

    Please can someone help me I have a blackberry playbook and I have tried to download games they do download onto play book but then when I go to play them I can't click on anything to play the game and all it says is delete please in easy to understant instructions tell me what I am doing wrong thanks

    Can anyone help me please as I dont know where to go to resolve this

Maybe you are looking for

  • Downloads to cell phones

    Anybody know how to download music from itunes to Motorola Razor and Samsung D807 phones? They are only set up for PC's. Attaching the phone to my iMac G5 via usb shows nothing on the screen to drag music to. Both phone companies say they only suppor

  • Automatic Find and Replace

    Is there any way to apply some kind of macro in CS3 that would automatically run a list of commands to change things such as specific strings of text to specific links I define. For example any time the words "Jeff Jefferson" come up in my Dream Weav

  • Acrobat problems?

    I'm using Word 2011 and Acrobat 9.0 Pro on a MacBook Pro that I just updated to Maverick. I converted a Word document into PDF, using the "print" option. Then I attempt to insert bookmarks into the PDF document -- as I've done a million times before.

  • Data exceeds its margin on web!

    GURUS !!! NEED HELP !!! We find some problems in reports while mirgating our client/server project to 9iAS forms/reports server. We are generating reports on 'pdf'. We found the following differences when compared same data on C/S and Web. (We used t

  • Bluetooth not available after memory upgrade

    Hi, I have a Macbook pro. I upgraded the memory from 2 GB to GB, Everything is working but the Bluetooth that says "Bluetooth not available". If i remove the memory the bluetooth works again. I tried also to put a bluetooth dongle and is the same. Th