Guest User

Soldier.java

a guest
Nov 13th, 2010
182
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Created by Brandon Golway
  2. //Custom Methods for the object Soldier
  3. //Edited on 11/13/2010
  4.  
  5. import java.util.*;
  6.  
  7. public class Soldier extends Person
  8. {
  9.     protected static int weight, age, height, money, strength, energy;
  10.     protected static String name, address ;
  11.    
  12.     public Soldier() //constructor to set variables
  13.     {
  14.         super(Height,  Weight,  Age,  Money ,  Energy,  Strength,  Name,  Address, true);
  15.        
  16.         int Weight = weight;
  17.         int Age = age;
  18.         int Height= height;
  19.         int Money= money;
  20.         int Strength= strength;
  21.         int Energy= energy;
  22.         String Name= name;
  23.         String Address= address;
  24.     }
  25.    
  26.     public void setWeight()
  27.     {
  28.         Random random = new Random();
  29.         int min = 125, max = 250 ; //soldier's weight will be between 125 and 250 Lbs.
  30.         weight = random.nextInt(max - min + 1) + min;
  31.     }
  32.    
  33.     public void setAge()
  34.     {
  35.         Random random = new Random();
  36.         int min = 18, max = 40 ; //soldier's age will be between 18 and 40
  37.         age = random.nextInt(max - min + 1) + min; //picks the random value
  38.     }
  39.    
  40.     public void setHeight()
  41.     {
  42.         Random random = new Random();
  43.         int min = 60, max =72 ; //soldier's height will be between 60 and 72 inches
  44.         height = random.nextInt(max - min + 1) + min;
  45.     }
  46.    
  47.     public void setMoney()
  48.     {
  49.         Random random = new Random();
  50.         int min = 0, max = 250 ; //soldier's money will be between 125 and 250 Lbs.
  51.         money = random.nextInt(max - min + 1) + min;
  52.     }
  53.    
  54.     public void setStrength()
  55.     {
  56.         Random random = new Random();
  57.         int min = 0, max = 30 ; //soldier's money will be between 125 and 250 Lbs.
  58.         strength = random.nextInt(max - min + 1) + min;
  59.     }
  60.    
  61.     public void setEnergy()
  62.     {
  63.         Random random = new Random();
  64.         int min = 0, max = 20 ; //soldier's money will be between 125 and 250 Lbs.
  65.         energy = random.nextInt(max - min + 1) + min;
  66.     }
  67.    
  68.    
  69.     public void setName()
  70.     {
  71.         System.out.print("Name your soldier: ");
  72.         Scanner scanner = new Scanner(System.in);
  73.         name = scanner.nextLine();     
  74.     }
  75.    
  76.     public void setAddress()
  77.     {
  78.         address = "Barracks";
  79.     }
  80.    
  81. }
RAW Paste Data