Hello! guys,
I am developing a java game, "the rabbit, turtle, bird," I have a small problem, I do not know how to put attributes to the objects created, for example, a goal of 60 feet, the turtle walks " shift "of 4-8 meters, 6-12 rabbit, but has a 60% chance falling asleep from lack of energy and lose two turns. and the bird moves from 9 to 16 spaces per shift but has a 45% chance to rest and lose three turns and 25% of feeding and losing four shifts., 60% falling asleep from lack of energy and lose two turns. Finally you have obtáculos for the rabbit and the bird, they will lose a turn, and the tortoise is not affected by OBSTACLES,
What do you recommend to make this work? How I can work the thread objects, the attributes of each object?
I'm working on this example.
public class Ejemplo21 {
static Animal tortuga;
static Animal liebre;
static Animal pajaro;
public static void main(String argv[])
throws InterruptedException {
tortuga = new Animal(2, "TORTUGA ");
liebre = new Animal(4, "LIEBRE ");
pajaro = new Animal(10, "PAJARO ");
tortuga.start();
liebre.start();
pajaro.start();
}
}
class Animal extends Thread {
String nombre;
public Animal(int prioridad, String nombre) {
this.nombre = nombre;
setPriority(prioridad);
}
@Override
public void run() {
for (int x = 0; x < 30; x++) {
yield();
}
System.out.println("\nLlega a meta "+nombre );
}
}
thanks a lot, for the people than showl be helme!!!