aspose file tools *
The moose likes Beginning Java and the fly likes Java code reuqired urgently Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

Java code reuqired urgently

kris chait
Greenhorn

Joined: Nov 24, 2008
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

Joined: Sep 07, 2004
Posts: 781

It will take me about two days to write this. Is this soon enough?


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8997
    
    9

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?


[How To Ask Questions On JavaRanch]
kris chait
Greenhorn

Joined: Nov 24, 2008
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

Joined: Aug 05, 2005
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.


Joanne
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10537
    
    9

Originally posted by Joanne Neal:

I suspect you may find this useful.


I beg to differ.
This would be more useful


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Joanne Neal
Rancher

Joined: Aug 05, 2005
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

Joined: Oct 13, 2005
Posts: 40079
    
  28
Sarcasm, irony, who cares. I'm moderating and I'm closing this thread as a duplicate.
 
 
subject: Java code reuqired urgently