SHARE
TWEET

Untitled

a guest Oct 21st, 2019 91 in 2 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package gamepvp;
  2. import java.util.Random;
  3. import java.util.Scanner;
  4. public class GamePVP {
  5.     public static void main(String[] args) {
  6.     Scanner NamesScanner = new Scanner(System.in);                                  // initialize scanners
  7.     Scanner Stats = new Scanner(System.in);
  8.     Scanner Choice = new Scanner(System.in);
  9.     System.out.println("How many character you want to create?");
  10.     int counter = Choice.nextInt();
  11.     Character players[]=new Character[counter];                                  // initialize array
  12.        
  13.     for(int a=0;a<counter;a++){                                                  //will create an object for each slot, will extract into creators class
  14.         String nameplayer;
  15.         System.out.println("please type the name of player "+a+1);
  16.         nameplayer = NamesScanner.nextLine();
  17.         players[a] = new Character (nameplayer);//this creates the object in the array
  18.     }                                                                           //end of obj creator block
  19.        
  20.     for(int b=0;b<counter;b++){                                                          //will assign stats to each object, will extract into statistics class.
  21.             System.out.println("set stats for"+players[b].name );
  22.             while(players[b].pointspool > 0){//this loop assigns stats until there is none left
  23.             boolean Complete; //tracks if character is completed at end of loop
  24.             System.out.println("you have "+players[b].pointspool+" points left" );
  25.             System.out.println("How much HP do you want?");                    
  26.             int HP = Stats.nextInt();                                           //
  27.             players[b].HP = HP;                                                     //this is a way to assign information to the object
  28.             players[b].pointspool = players[b].pointspool-HP;                          
  29.             //-----------------------------------------------------------------//
  30.             System.out.println("you have "+players[b].pointspool+" points left" );  
  31.             System.out.println("How much Atk do you want?");            
  32.             players[b].ATK = Stats.nextInt();                                       //a different way to set it
  33.             players[b].pointspool = players[b].pointspool-players[b].ATK;
  34.             System.out.println("you have "+players[b].pointspool+" points left" );
  35.             System.out.println("you have: "+players[b].HP+" HP and "+players[b].ATK+" ATK");
  36.             //-----------------------------------------------------------------//
  37.             System.out.println("you have "+players[b].pointspool+" points left" );  
  38.             System.out.println("How much Mana do you want?");
  39.             players[b].SetMana(Stats.nextInt());                                    //even shorter way, with methods in the object and passing a parameter.
  40.             //-----------------------------------------------------------------//
  41.             players[b].SetSpeed();                                                  // how to use an even faster method to set stats
  42.             //-----------------------------------------------------------------//
  43.                 if(players[b].pointspool>0){
  44.                 System.out.println("you still have points left!");
  45.             }
  46.             System.out.println("do you want this stats? yes 1 no 0");
  47.             int Choiceint = Choice.nextInt();
  48.             if(Choiceint==0){players[b].pointspool=100;}
  49.     }
  50. }                                                                               //end of statistics setting block
  51. }
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top