-1
I need to register the following event in my program:
- Players who kill 5 times during the 1 minute break will win a prize.
My class mapping is as follows:
public class Game {
private String name;
private HashMap<String,Player> players;
private Player serialKiller;
private Integer streak;
}
public class Player implements Comparable<Player> {
private String name;
private List<Murder> murderList = new ArrayList<Murder>();
private List<Death> deathList = new ArrayList<Death>();
}
public class Murder {
private Date date;
}
Log file:
30/07/2013 15:34:22 - New match 11348965 has Started
30/07/2013 15:36:04 - Roman nick Killed using M16
30/07/2013 15:36:05 - Roman Killed Mane using M16
30/07/2013 15:36:06 - Roman Killed Jose using M16
30/07/2013 15:36:07 - Roman Killed Trevis using M16
30/07/2013 15:36:08 - Roman Killed Santana using M16
30/07/2013 15:36:05 - noob1 Killed noob2 using M16
30/07/2013 15:36:06 - noob1 Killed noob3 using M16
30/07/2013 15:36:07 - noob1 Killed noob4 using M16
30/07/2013 15:36:07 - noob10 Killed noob1 using M16
30/07/2013 15:36:07 - noob10 Killed noob1 using M16
30/07/2013 15:36:07 - noob10 Killed noob1 using M16
30/07/2013 15:36:07 - noob10 Killed noob1 using M16
30/07/2013 15:36:07 - noob10 Killed noob1 using M16
30/07/2013 15:36:07 - noob10 Killed noob1 using M16
30/07/2013 15:36:07 - noob10 Killed noob1 using M16
30/07/2013 15:36:07 - noob10 Killed noob1 using M16
30/07/2013 15:36:07 - noob10 Killed noob1 using M16
30/07/2013 15:36:33 - Killed Nick by DROWN
30/07/2013 15:39:22 - Match 11348965 has ended
The time Date
of the death of opponents is defined in the user class by the Murder class list.
How can I know if the player will win the prize without using Threads ?
Create a Thread that checks and counts system time. Doubt: Do you need all 4 next deaths to be in less than 60s of the first? Or can you implement to check if there have been more than 5 deaths in a minute?
– Mansueli
@Kyllopardiun the stop is like this, I am uploading a log of a file that has the departure information... then from it I submit the information.... and on "Doubt: need all the next 4 deaths to be in less than 60s of the first?" Yes need to occur in a 1-minute range
– Vinícius Carneiro de Brito
Take a look at this link here: http://www.java2s.com/Code/Java/Threads/Simple-Threads.htm It teaches how to make threads...what you need is to make a thread run for 60 seconds decreasing and doing something like a "deaths++" and if it reaches 5 you fire your event.
– Dante
@Dante I’m not seeing the need to use a thread, since I already have everything, the amount of murders the guy has and the date he killed... the file I upload tells me that understand??? I’m not sure how to use the information...
– Vinícius Carneiro de Brito
then put the file in your question and also put the part of the code that reads it.
– Marciano.Andrade
@Blacksheep, would you mind using
JavaFX
in a solution?– Mansueli
If you already have all the information what is missing? Make a code that reads the file (which should be in text format probably) and each line identifies who the guy is by name and adds 1 kill to him according to the time differential
– Dante