Android Open Source - KanaDrill Common Code






From Project

Back to project page KanaDrill.

License

The source code is released under:

Copyright (c) 2014, Jorge Castillo All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...

If you think the Android project KanaDrill listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.jorgecastillo.kanadrill;
/*from  w w  w  .j av a2s.  co  m*/
import java.util.Arrays;

public class CommonCode {

  public static void orderLinear(int upto, int order[]) {

    for (int i = 0; i < upto; i++) {
      order[i] = i;
    }

  }
  
  private static boolean intExists(int[] vector, int element, int length) {

    for(int i = 0; i < length; i++) {
      if (vector[i] == element) {
        return true;
      }
    }

    return false;  

  }

  public static void orderRandom(int upto, int order[]) {

    Arrays.fill(order, -1);

    for (int i = 0; i < upto;) {
      int val = randomInt(upto);
      if (!intExists(order, val, upto)) {
        order[i] = val;
        i++;
      }
    }

  }

  public static int setUpto(int option) {

    int upto = 0;

    switch(option) {
    case 1:
      upto = 46;
      break;
    case 2:
      upto = 71;
      break;
    case 3:
      upto = 92;
      break;
    case 4:
      upto = 107;
      break;
    default:
      break;
    }

    return upto;

  }

  public static int randomInt(int upto) {

    int number;

    number = (int) Math.floor(Math.random() * upto);

    return number;
  }
}




Java Source Code List

com.jorgecastillo.kanadrill.CommonCode.java
com.jorgecastillo.kanadrill.GameActivity.java
com.jorgecastillo.kanadrill.MainActivity.java
com.jorgecastillo.kanadrill.SettingsActivity.java
com.jorgecastillo.kanadrill.TrainingActivity.java