mercredi 2 septembre 2020

How do i make a random number array that has predefined variables?

basicaly I want to make an array of random numbers between 0-20(which have variables already) and be able to print this array. It is for dnd character creation /and txt rpg based on your choices the story should divert drastically/(wanted to make a player class) i tried the following( i am a total noob btw):

public class Player {
public static void main (String[] args) {
}
 
public int dex1;//these are the random numbers between 0-20
public int dex2 = (int) (Math.random() * 5) + 1;//would need another array for the 5's
public int str1;
public int str2 = (int) (Math.random() * 5) + 1;
public int const1;
public int const2 = (int) (Math.random() * 5) + 1;
public int int1;
public int int2 = (int) (Math.random() * 5) + 1;
public int wis1;
public int wis2 = (int) (Math.random() * 5) + 1;
public int cha1;
public int cha2 = (int) (Math.random() * 5) + 1;
public int acro = (int) (Math.random() * 5) + 1;
public int animal = (int) (Math.random() * 5) + 1;
public int arcana = (int) (Math.random() * 5) + 1;
public int athlet = (int) (Math.random() * 5) + 1;
public int decept = (int) (Math.random() * 5) + 1;
public int history = (int) (Math.random() * 5) + 1;
public int insight = (int) (Math.random() * 5) + 1;
public int intimi = (int) (Math.random() * 5) + 1;
public int investigation = (int) (Math.random() * 5) + 1;
public int medic = (int) (Math.random() * 5) + 1;
public int nature = (int) (Math.random() * 5) + 1;
public int percep = (int) (Math.random() * 5) + 1;
public int perform = (int) (Math.random() * 5) + 1;
public int stealth = (int) (Math.random() * 5) + 1;
public int survival = (int) (Math.random() * 5) + 1;
public int gold = (int) (Math.random() * 25) + 1;
public int Armor;
public int hp = (int) (Math.random() * 14) + 1;//and 3 rd array for irregulars like hp, armor,      movementspd...
public int initiative = (int) (Math.random() * 5) + 1;
public int movementspd = (int) (Math.random() * 30) + 1;
public int persuasion = (int) (Math.random() * 5) + 1; 
public int religion = (int) (Math.random() * 5) + 1;
public int sleight = (int) (Math.random() * 5) + 1;
 
public int roll;
public int rpersu = roll+persuasion;
public int rinvestigation = roll+investigation;

public void main1(String[] args) {
        int i;
        int[] Stats = new int[8];
        for(int i1 = 0; i1 <  Stats.length; i1++) {
            Stats[i1] = (int)(Math.random() * 20+1);
            System.out.print(Stats[i1] + "  ");
            int[] Stats1 = {dex1, str1,const1,int1,wis1, cha1,Armor,roll};}
        System.out.println(Stats);
        }

}




Aucun commentaire:

Enregistrer un commentaire