Win a copy of Functional Reactive Programming this week in the Other Languages forum!

# Java code reuqired urgently

kris chait
Greenhorn
Posts: 4
I need java source for this problem..

Eating monsters, rules:
- There are 5 monsters, each monster having 5 calories to start with.
- Each monster is served a packet of food per round
- The food packet contains everything from 0 to 2 calories
- Each monster waits some random time before starting to eat their food
- When the food is eaten by a monster, it's number of calories will
increase with the number of calories contained in the food packet
- A monster will burn one calorie each time it eats
- Statistically, every 5th packet of food is poisoned
- If a monster eats a poisoned packet of food, it will loose that number of calories
- All monsters must finish eating before the next round of servings
- The strongest monsters eats statistically first, the time to wait from they
are served their food is calculated from how many calories they have in them.
- One monster will also steal food from another random monster per round of serving.
It is the first monster waking up that will steal from the others. This is done before
it will eat its own packet of food.
- If either the monsters food or the stolen food, the combimed food packet
will also be poisoned.
- A monster is dead if it no longer has any calories, and it will no
longer be a participant in the food fight

Out put example :
Monster 0 stole the food from monster 3
Oh no, monster 1 was poisoned: 2 calories left
monster 0(6) monster 1(2) monster 2(4) monster 3(4) monster 4(6)
Monster 2 stole the food from monster 4
Oh no, monster 2 was poisoned: 1 calorie left
monster 0(6) monster 1(3) monster 2(1) monster 3(3) monster 4(5)
Monster 4 stole the food from monster 1
Oh no, monster 4 was poisoned: 3 calories left
Oh no, monster 3 was poisoned: 2 calories left
Oh no, monster 2 was poisoned and died
monster 0(6) monster 1(2) monster 2(X) monster 3(2) monster 4(3)
Monster 0 stole the food from monster 1
Oh no, monster 4 was poisoned and died
monster 0(8) monster 1(2) monster 2(X) monster 3(1) monster 4(X)
Monster 1 stole the food from monster 0
monster 0(7) monster 1(2) monster 2(X) monster 3(X) monster 4(X)
Monster 1 stole the food from monster 0
monster 0(7) monster 1(5) monster 2(X) monster 3(X) monster 4(X)
Monster 0 stole the food from monster 1
monster 0(6) monster 1(5) monster 2(X) monster 3(X) monster 4(X)
Monster 0 stole the food from monster 1
monster 0(7) monster 1(5) monster 2(X) monster 3(X) monster 4(X)
Monster 0 stole the food from monster 1
monster 0(7) monster 1(5) monster 2(X) monster 3(X) monster 4(X)
Monster 1 stole the food from monster 0
Oh no, monster 1 was poisoned: 3 calories left
monster 0(7) monster 1(3) monster 2(X) monster 3(X) monster 4(X)
Monster 1 stole the food from monster 0
Oh no, monster 1 was poisoned and died
monster 0(7) monster 1(X) monster 2(X) monster 3(X) monster 4(X)
The winner is monster 0 with 7 calories left

James Sabre
Ranch Hand
Posts: 781
It will take me about two days to write this. Is this soon enough?

Joe Ess
Bartender
Posts: 9319
10
You have already been told that we will not do your homework for you.
Have you tried to solve the problem yourself? Do you have some code to share?

kris chait
Greenhorn
Posts: 4
James Sabre ,

It should be fine .. You can take your 2 days time and let me know the java code ...

Thanks
kris

Joanne Neal
Rancher
Posts: 3742
16
Originally posted by kris chait:
James Sabre ,

It should be fine .. You can take your 2 days time and let me know the java code ...

Thanks
kris

I suspect you may find this useful.

Maneesh Godbole
Saloon Keeper
Posts: 11185
15
Originally posted by Joanne Neal:

I suspect you may find this useful.

I beg to differ.
This would be more useful

Joanne Neal
Rancher
Posts: 3742
16
Originally posted by Maneesh Godbole:

I beg to differ.
This would be more useful

True, but as sarcasm is a form of irony, I thought (in the JavaRanch manner of guiding rather than telling) I'd give the OP a general overview and let him decide on James's specific intention.

Campbell Ritchie
Sheriff
Posts: 50240
79
Sarcasm, irony, who cares. I'm moderating and I'm closing this thread as a duplicate.