How to repeat an action N times without using a for loop [on hold]

Home / Uncategorized / How to repeat an action N times without using a for loop [on hold]

Pardon me for my bad english. I am working on a Lotto system, the idea is to have positions like 1st Position, 2nd Positon and each position has a prize and number of winners needed for that position, so we can have like 5 winners for a given position, these positions are kept in an arrayList, issues comes in when you want to start the draw.

Here is the structure of the position Object
public class Position implements Serializable{

private int id;
private String name;
private String prize;
private int numOfWinners;
private int winnerId;

So I put a finite number of positions in an arrayList
ArrayList positions;
Then when a user clicks on a button the system gets the a position using this code
if(currentPosition < draw.getPositions().size() && !this.isIsDrawDone()){ pos = draw.getPositions().get(currentPosition); updatePositionViews(pos); this.currentCounterRepeat ++; } And the system starts getting random user Ids from the database, when a user clicks the stop button the current userId is declared the winner for that position, when the user clicks the start button again the system either lets the user do another draw for that Id "Repeats" since we probably need multiple winners for that position or moves to the next position, that is why I do not use a conventional for loop because I wait for a winner to move to the next position or repeat the current position, issue is I cannot come up with the logic to repeat the current position incase we need multiple winners for it.


Read more

Leave a Reply

Your email address will not be published. Required fields are marked *