Java Array Convert to convertArrayIndexToShipLetter(int i)

Here you can find the source of convertArrayIndexToShipLetter(int i)

Description

convert Array Index To Ship Letter

License

Open Source License

Declaration

public static String convertArrayIndexToShipLetter(int i) 

Method Source Code

//package com.java2s;
/**//from www  .j a  v a  2 s . c  o m
 *  Copyright (C) 2003-2012  Joe Hopkinson, Jay Ashworth
 *
 *  JavaTrek is based on Chuck L. Peterson's MTrek.
 *
 *  This file is part of JavaTrek.
 *
 *  JavaTrek is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  JavaTrek is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with JavaTrek; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

public class Main {
    public static String convertArrayIndexToShipLetter(int i) {
        // in the array, 123...890 takes up the first 10, ABC...XYZ, the next 26, and abc...xyz the final 26
        if (i >= 0 && i <= 9) {
            i += 48;
        } else if (i >= 10 && i <= 35) {
            i += 65;
        } else if (i >= 36 && i <= 51) {
            i += 97;
        }
        return (Character.toString((char) i));
    }
}

Related

  1. arrayWithoutFirstsElement(final String[] array, final int elementsToRemove)
  2. convertArray(byte[] a)
  3. convertArray(Object columns[], int minLength)
  4. convertArray(String[] str)
  5. convertArray2String(String[] sources)
  6. convertArrayToCSVString(String[] s)
  7. convertArrayToInteger(String[] input)
  8. convertArrayToLine(String[] cols)
  9. convertArrayType(String type)