Ask your own question, for FREE!
Computer Science 14 Online
OpenStudy (davidusa):

JAVA PROGRAMMING HELP PLEASE!

OpenStudy (davidusa):

hi!

OpenStudy (davidusa):

FINALLY

OpenStudy (davidusa):

so, my problem is this hare v tortoise race

OpenStudy (davidusa):

right now im just starting, this is not anywhere near the final.

OpenStudy (dan815):

Okay whats the problem

OpenStudy (davidusa):

heres the program, it never works...

OpenStudy (dan815):

What does it have to do

OpenStudy (davidusa):

Here's the instructions

OpenStudy (davidusa):

It's supposed to show the rabbit and turtle on different sides of a line and then they're supposed to move a little.

OpenStudy (davidusa):

But it doesn't compile so it cant do that

OpenStudy (nincompoop):

type your code here

OpenStudy (dan815):

Okay pretty cool and simple

OpenStudy (dan815):

Make N number of arrays given the N number of players

OpenStudy (dan815):

Make them all object arrays

OpenStudy (dan815):

ASsign player classes

OpenStudy (dan815):

hare and tortoise, Use random command, let k be a number for the number of available moves for the player class type. generate a random int {1,2,3...K}

OpenStudy (dan815):

And you're done, all that's left is updating the objective array belonging to each player

OpenStudy (dan815):

make a move command, that "rolls the dice", and refreshes the position based on value of roll"

OpenStudy (dan815):

if {player}{placearray}{pos}>50, return {player},"winner" and end game

OpenStudy (dan815):

need to deal with some bounds though

OpenStudy (davidusa):

Yea i know about the dice but how do i make this program work

OpenStudy (dan815):

if player{pos} <0, then play pos =0

OpenStudy (davidusa):

i know @Dark_Riddles help

OpenStudy (dan815):

^java pro

OpenStudy (davidusa):

yep

OpenStudy (davidusa):

@Dark_Riddles HELP ME PLZ

OpenStudy (anonymous):

Do you need it to be fixed or someone to complete it?....

OpenStudy (davidusa):

fixed

OpenStudy (davidusa):

I'll complete it later, but I just want to know why this isn't working and how to fix it

OpenStudy (anonymous):

Alright, I'll have a look after im done eating my lunch, 15-30 mins or so

OpenStudy (davidusa):

Ok thanks

OpenStudy (anonymous):

I don't understand your code?

OpenStudy (anonymous):

public void delay () { for (int i = 0; i<=90000000; i++ ); } { delay(); delay(); delay(); } { g.drawImage( Rabbit, 90, 20, 160, 100 , this ); g.drawImage( Turtle, 30, 200, 160, 100, this ); } } That's going to go in an infinite loop for eternity

OpenStudy (anonymous):

That last part if the method is never reached. Its stuck in an infinity loop, above ^

OpenStudy (davidusa):

OH.

OpenStudy (anonymous):

Understand?

OpenStudy (davidusa):

I understand, but how do I make the program wait a few seconds before making another turtle and rabbit?

OpenStudy (davidusa):

HELP ME THE RABBIT NEEDS TO MOVE

OpenStudy (anonymous):

hey are u good with java im kind of new to it and need some help and your like only person here

OpenStudy (davidusa):

what u need kk ill help

OpenStudy (anonymous):

oops i got it :D

OpenStudy (davidusa):

@mathmale plz look at my message

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!