Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.ArrayList;

import java.util.Random;

public class Main {
    static ArrayList<String> h_fnpre = new ArrayList<String>();
    static ArrayList<String> h_fnsuf = new ArrayList<String>();
    static ArrayList<String> h_lnpre = new ArrayList<String>();
    static ArrayList<String> h_lnsuf = new ArrayList<String>();
    static ArrayList<String> o_fnpre = new ArrayList<String>();
    static ArrayList<String> o_fnsuf = new ArrayList<String>();

    public static String generateNickname() {
        Random rnd = new Random(System.currentTimeMillis());
        int race_selection = rnd.nextInt(3);

        String thefirstname = "";
        String thelastname = "";
        String thefirstname1 = "";
        String thelastname1 = "";

        if (race_selection == 0) {
            double fnprefix1 = Math.floor(Math.random() * 122);
            double fnsuffix1 = Math.floor(Math.random() * 91);
            double lnprefix1 = Math.floor(Math.random() * 67);
            double lnsuffix1 = Math.floor(Math.random() * 64);

            thefirstname = h_fnpre.get((int) fnprefix1) + h_fnsuf.get((int) fnsuffix1);
            thelastname = h_lnpre.get((int) lnprefix1) + h_lnsuf.get((int) lnsuffix1);

            thefirstname1 = thefirstname.substring(0, 1).toUpperCase();
            thefirstname = thefirstname1 + thefirstname.substring(1, thefirstname.length());

            thelastname1 = thelastname.substring(0, 1).toUpperCase();
            thelastname = thelastname1 + thelastname.substring(1, thelastname.length());

        } else if (race_selection == 0) {
            double fnprefix1 = Math.floor(Math.random() * 80);
            double fnsuffix1 = Math.floor(Math.random() * 67);

            thefirstname = o_fnpre.get((int) fnprefix1) + o_fnsuf.get((int) fnsuffix1);
            thelastname = "";

        } else {
            double fnprefix1 = Math.floor(Math.random() * 122);
            double fnsuffix1 = Math.floor(Math.random() * 91);

            thefirstname = h_fnpre.get((int) fnprefix1) + h_fnsuf.get((int) fnsuffix1);

        }

        return thefirstname + " " + thelastname;
    }
}