Behind the scenes: @cryptocameo's glass giveaway contest!

in #glass8 years ago (edited)

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;
import static java.lang.System.out;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;

public class WinnerPicker {

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 
    }  
}

}

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...

hint: more to come in the future perhaps ;)

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 :)

Sort:  

Sorry everybody! It looks like my original video link broke! You can find a mirror I've uploaded here!

Amazing work! Thanks for your help @desmonid

This will be a lot of fun.

nice job, really cool way to do a giveaway