File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
    Bookmark Topic Watch Topic
  • New Topic

Java code reuqired urgently

 
kris chait
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Java Netbeans IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
It will take me about two days to write this. Is this soon enough?
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 3742
16
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Originally posted by Joanne Neal:

I suspect you may find this useful.


I beg to differ.
This would be more useful
 
Joanne Neal
Rancher
Pie
Posts: 3742
16
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 47243
52
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Sarcasm, irony, who cares. I'm moderating and I'm closing this thread as a duplicate.
 
    Bookmark Topic Watch Topic
  • New Topic