I am making code to try to make a game and my problem is that my code......

I am making code to try to make a game and my problem is that my code
will not let it change the hit everytime so im getting the first guy to hit 1 then next hits 8 and so on and always repeats.
Another problem is that I would like it to attack with out me telling it how much times to attack. I am using Object oriented programming.
Here is the code for my objects:
import java.lang.*;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.Random;
import static java.lang.Math.*;
import java.awt.*;
import java.awt.color.*;
class rockCrab {
     //Wounding formula
     double sL = 70;                                   // my Strength Level
     double bP = 1;                                   // bonus for prayer (is 1 times prayer bonus)
     double aB = 0;                                 // equipment stats
     double eS = (sL * bP) + 3;                         // effective strength
     double bD = floor(1.3 + (eS/10) + (aB/80) + ((eS*aB)/640));     // my base damage
     //Attack formula
     double aL = 50;                                   // my Attack Level
     double eD = 1;                                   // enemy's Defence
     double eA = aL / eD;                              // effective Attack
     double eB = 0;                                   // equipment bonus'
     double bA = ((eA/10) * (eB/10));                    // base attack
     //The hit formula
     double fA = random() * bA;
     double fH = random() * bD;
     double done = rint(fH - fA);
     //health formula
     double health = floor(10 + sL/10 * aL/10);
     rockCrab() {
     void attack() {
          health = floor(10 + sL/10 * aL/10);
          double done = rint(fH - fA);
          fA = random() * bA;
          fH = random() * bD;
          done = rint(fH - fA);
          System.out.println("Rockcrab hit" +done);
import java.lang.*;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.Random;
import static java.lang.Math.*;
import java.awt.*;
import java.awt.color.*;
class self {
     //Wounding formula
     double sL = 1;                                   // my Strength Level
     double bP = 1;                                   // bonus for prayer (is 1 times prayer bonus)
     double aB = 0;                                 // equipment stats
     double eS = (sL * bP) + 3;                         // effective strength
     double bD = floor(1.3 + (eS/10) + (aB/80) + ((eS*aB)/640));     // my base damage
     //Attack formula
     double aL = 1;                                   // my Attack Level
     double eD = 1;                                   // enemy's Defence
     double eA = aL / eD;                              // effective Attack
     double eB = 0;                                   // equipment bonus'
     double bA = ((eA/10) * (eB/10));                    // base attack
     //The hit formula
     double fA = random() * bA;
     double fH = random() * bD;
     double done = rint(fH - fA);
     //health formula
     double health = floor(10 + sL/10 * aL/10);
     self() {
     void attack() {
          health = floor(10 + sL/10 * aL/10);
          fA = random() * bA;
          fH = random() * bD;
          done = rint(fH - fA);
          System.out.println("You hit" +done);
}Here is the main code that writes what the objects do:
class fight {
     public static void main(String[] args) {
          self instance1 = new self();
          rockCrab instance2 = new rockCrab();
          instance2.health = instance2.health - instance1.done;
          System.out.println("You hit: " +instance1.done);
          System.out.println("rockCrabs health: " + instance2.health);
          instance1.health = instance1.health - instance2.done;
          System.out.println("RockCrab hit: " +instance2.done);
          System.out.println("rockCrabs health: " + instance1.health);
          instance2.health = instance2.health - instance1.done;
          System.out.println("You hit: " +instance1.done);
          System.out.println("rockCrabs health: " + instance2.health);
          instance1.health = instance1.health - instance2.done;
          System.out.println("RockCrab hit: " +instance2.done);
          System.out.println("rockCrabs health: " + instance1.health);
          instance2.health = instance2.health - instance1.done;
          System.out.println("You hit: " +instance1.done);
          System.out.println("rockCrabs health: " + instance2.health);
          instance1.health = instance1.health - instance2.done;
          System.out.println("RockCrab hit: " +instance2.done);
          System.out.println("rockCrabs health: " + instance1.health);
          instance2.health = instance2.health - instance1.done;
          System.out.println("You hit: " +instance1.done);
          System.out.println("rockCrabs health: " + instance2.health);
          instance1.health = instance1.health - instance2.done;
          System.out.println("RockCrab hit: " +instance2.done);
          System.out.println("rockCrabs health: " + instance1.health);
}when the code is run it says something like this:
you hit 1
RockCrabs health is 9
RockCrab hit 7
your health is 38
you hit 1
RockCrabs health is 8
RockCrab hit 7
your health is 31
you hit 1
RockCrabs health is 7
RockCrab hit 7
your health is 24
you hit 1
RockCrabs health is 6
RockCrab hit 7
your health is 17
my point is whatever some one hits it always repeats that
my expected output would have to be something like
you hit 1
RockCrabs health is 9
RockCrab hit 9
your health is 37
you hit 3
RockCrabs health is 6
RockCrab hit 4
your health is 33
you hit 2
RockCrabs health is 4
RockCrab hit 7
your health is 26
you hit 3
RockCrabs health is 1
RockCrab hit 6
your health is 20
Edited by: rade134 on Jun 4, 2009 10:58 AM

[_Crosspost_|http://forums.sun.com/thread.jspa?threadID=5390217] I'm locking.

Similar Messages

Maybe you are looking for

  • Error Message: Motion menus exceed maximum duration

    Our iDVD has one Main Menu with Nine Submenu's. We used the Reflections Theme. All these have motion menus, for consistency. Each is set at a loop duration for audio of no more than 45 seconds. [10X45=450 secs or 7:30 mins]. The menu screeen allows f

  • Log off functionality in different languages

    Hi, In SICF i configured a Logoff page according to: http://help.sap.com/saphelp_nw04s/helpdata/en/fc/04a5421935c511e10000000a1550b0/content.htm It works fine in english but can´t get it to work in danish. I have tried to maintain the service in lang

  • Photoshop CS3 help needed

    My Photoshop CS3 extended when loaded on my laptop causes all of my desk top icons to turn to photoshop, the only program that will open is photoshop. This program until recently worked great. Anyone with answers would be a big help. Thanks Jess

  • Alcor card reader not recognising SD card, Windows 8.1

    My card reader stopped reading my SD card (formatted for Nikon SLR).  I hunted around and saw that the only new software on the PC was the Alcor software, so I uninstalled it and, hey presto!, the card reader works again. However, the HP update servi

  • Serious problem with my MB....

    A few minutes ago, I downloaded a program to convert a movie to an iPod Touch. After starting the conversion, it said it was going to take several hours. Shortly thereafter, the fan kicked up to 6500 rpm and I decided to "bail". With no apparent prog