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
-
hello, im unable to make an icloud account on my iphone, because whenever i make an account, a messege appears that this device has enough accounts so you can not make a new one, so the problem is that i dont konw about the perevious accounts, what should i do to delete pervious accounts and create a new one?
The problem is that there is a limit for creating new iCloud accounts from a device and if the previous owner already created three accounts with this iPhone you bought from him, then you would have to use another device in order to create a new one.
-
I try to export my Imovie and I always get the error code"Unable to prepare project for publishing...File already open with write permission" it even does it when I am just trying to export to my external hard drive to save the file
Thanks!!! I had same error (with -49) and the mac had an external hard drive attached.. and it was doing a backup. Stopped, disconnected and the project exported!
-
Every time i try to make a game centre account it tells me that the question id was not found, can you please help me!
Thanks!*I have no other computers authorized.
-
Why when i try to make a purchase, keep getting a table that says ''your purchase can not be complete?''
Gramma56 wrote:
... How do I fix this problem?
Contact iTunes Support as requested...
http://www.apple.com/support/itunes/contact.html -
Please help on how to fix this error message when I'm trying to connect on my VPN
Connection error. Try again. Check configuration and if problem persists contact the administrator.Thanks for the info.
-
I just got a new iphone 5,and when I try to update my phone, and install the aps that I've already purchased onto it, it says I don't have permission to do so.
Contact your carrier & have them reset your Voicemail. Most carriers require such, so after they reset it, just set it up again.
-
hi need your help.
updted my iphone 4 today on ios 7.0.4 and now with new start code required, what i never had before and i don't know the code.
how can i get this problem solved?
thx
peterHere's how you put it into recovery mode
1: Turn off your iPHone by holding the sleep/wake button till it says "Slide to power off."
2: Hold down the home button (Button on the bottom of the display with a square in the middle) and connect it to the computer while still holding it down till you see a music note with an arrow pointing towards it appear on the screen of your iPhone
3: iTunes will give you a message, "iTunes has detected a device in recovery mode; you must restore this device to factory settings to use this device."
4: Click on "Restore iPHone."
http://support.apple.com/kb/HT1808 if you want apple article steps -
i want to update my apps on my iphone4 and when i go to update them a message keeps popping up saying "sign in to varify your acount" i sign in then it takes me to a billing page i put in all of my billing information and it says security code wrong i i have the Mastercard infront of me every time i try to do this and it tells me that i have an "invalid security code"
Might be an address formatting issue with your iTunes account records. See http://support.apple.com/kb/TS1646.
-
When ever I try to download a game I get a message that I am not connect to the internet
when I try to download a game from any website, I get a message that says;
A network related error has occurred. Please ensure your computer is connected to the internet and click yes to retry now or no to exit. If I click yes I get the error again.
What can I do to fix this problem?These errors typically occur when security software interferes with the restore and update process. FollowTroubleshooting security software issues to resolve this issue. In rare cases, these errors may be a hardware issue. If the errors persist on another computer, the device may need service.
Also, check your hosts file to verify that it's not blocking iTunes from communicating with the update server. See iTunes: Advanced iTunes Store troubleshooting—follow steps under the heading Blocked by configuration (Mac OS X / Windows) > Rebuild network information > Mac OS X > The hosts file may also be blocking the iTunes Store. If you have software used to perform unauthorized modifications to the iOS device, uninstall this software prior to editing the hosts file to prevent that software from automatically modifying the hosts file again on restart.
http://support.apple.com/kb/TS3694 -
This morning I found my MacBook screen was dark, no response. The power light was on, it's been plugged in and that seems to be working. I powered it down and when I hit power to turn it back on it made an electronic pattern of tones. After that...nothing. Dark screen, power light on. I'd love some advice.
Try this.
Erase and Reinstall OS X
Note: This will delete all data on the disk. Back up important files before continuing.
Erasing and then reinstalling OS X can give you a fresh start, making your computer exactly as it was whenever you received it from Apple. This can solve various problems such as corrupt system files.
Shut down the computer by going to Apple () > Shut Down…
Select Shut Down or allow the computer to shut down automatically.
Plug in the MagSafe power adapter into a power source and then connect it to your Mac if you have not already done so.
Press the Power Button to turn on the computer.
Press and hold both the R and Command (⌘) keys on the keyboard until the Recovery partition loads.
Select Disk Utility and then choose Continue.
Select your startup disk (Macintosh HD by default) from the left.
Select the Erase tab.
Choose the Format pop-up menu and choose Mac OS Extended (Journaled), enter a name for your disk, and then click Erase.
After the disk is erased, choose Disk Utility > Quit Disk Utility.
Select Reinstall OS X and then choose Continue.
Follow the instructions.
I hope I solved your question.
Austin -
Why is that?
Same problem here... it always happens at the end of the registration process whether I try on the phone or the mac. My other account works fine, but I want to create a new account for testing our game.
-
i have filled in all the right information but it is still saying invalid
Hey markjamesmill,
there is only one resolution ... contact iTunes Support -
Also, when I tried to connect my iPod to my MacBook Pro, and sync it into iTunes, 'iTunes could not connect to this iPhone.' First it's not an iPhone, and second, my iPod could sync perfectly fine before the wifi problem. Is there a way to return it back to normal; fix it? Someone please answer.
Does the iOS device connect to other networks?
Does the iOS device see the network?
Any error messages?
Do other devices now connect?
Did the iOS device connect before?
Try the following to rule out a software problem:
- Reset the iOS device. Nothing will be lost
Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
least ten seconds, until the Apple logo appears.
- Power off and then back on your router
.- Reset network settings: Settings>General>Reset>Reset Network Settings
- iOS: Troubleshooting Wi-Fi networks and connections
- Wi-Fi: Unable to connect to an 802.11n Wi-Fi network
- iOS: Recommended settings for Wi-Fi routers and access points
- Restore from backup. See:
iOS: How to back up
- Restore to factory settings/new iOS device.
If still problem make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
Apple Retail Store - Genius Bar -
Anyone know how to fix it?
Try:
- Reset the iOS device. Nothing will be lost
Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
least ten seconds, until the Apple logo appears.
- Go to Settings>Game Center and sign out and sign back in
- Reset all settings
Go to Settings > General > Reset and tap Reset All Settings.
All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
- Restore from backup. See:
iOS: How to back up
- Restore to factory settings/new iOS device.
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
-
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