Greetings steemers! You may have just arrived here from @cryptocameo's glass giveaway post, but if not you should definitely click that link and go check it out ;)
I will be acting as an impartial judge for the contestants in the giveaway
I'll be using the program below to pick the winners, here's an easy to read screenshot as well as the full copy/pasteable text for those of you who might be so inclined to run it. package winnerpicker; public class WinnerPicker { } So, basically what this code does is take a list of n contestants and rank them in a random order. All contestants will be able to see what place they got for full transparency, but only the first x contestants will get prizes as outlined by the rules of the specific giveaway... Here you can find a brief video of me explaining the code: I'm not going to teach you java in 5 minutes but hopefully even if you don't know anything about code you'll be able to grasp what is going on from watching the following enough to understand the contest! Feel free to ask questions below in the comment section :)
import static java.lang.System.out;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;public static void main(String[] args) {
ArrayList<String> contestants=new ArrayList<>();//build contestants arraylist
String[] dumpToContestants= new String[]{"a","b","c","d","e","f","g","h"}; //this is the list of contestants
contestants.addAll(Arrays.asList(dumpToContestants));//dump list of contestants into arraylist
out.println("The contestants are "+Arrays.toString(contestants.toArray()));
Random r = new Random();
int result=0;
int place=1;
while(contestants.isEmpty()==false)//keep choosing winners until there are no more contestants
{
result=r.nextInt(contestants.size());
out.println("["+place+"]:"+contestants.get(result));//declare contestant's ranking overall
contestants.remove(result);
place++; //increment place variable before moving on to next contestant
}
}
hint: more to come in the future perhaps ;)
Sorry everybody! It looks like my original video link broke! You can find a mirror I've uploaded here!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Amazing work! Thanks for your help @desmonid
This will be a lot of fun.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
nice job, really cool way to do a giveaway
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit