Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Created by Brandon Golway
- //Custom Methods for the object Soldier
- //Edited on 11/13/2010
- import java.util.*;
- public class Soldier extends Person
- {
- protected static int weight, age, height, money, strength, energy;
- protected static String name, address ;
- public Soldier() //constructor to set variables
- {
- super(Height, Weight, Age, Money , Energy, Strength, Name, Address, true);
- int Weight = weight;
- int Age = age;
- int Height= height;
- int Money= money;
- int Strength= strength;
- int Energy= energy;
- String Name= name;
- String Address= address;
- }
- public void setWeight()
- {
- Random random = new Random();
- int min = 125, max = 250 ; //soldier's weight will be between 125 and 250 Lbs.
- weight = random.nextInt(max - min + 1) + min;
- }
- public void setAge()
- {
- Random random = new Random();
- int min = 18, max = 40 ; //soldier's age will be between 18 and 40
- age = random.nextInt(max - min + 1) + min; //picks the random value
- }
- public void setHeight()
- {
- Random random = new Random();
- int min = 60, max =72 ; //soldier's height will be between 60 and 72 inches
- height = random.nextInt(max - min + 1) + min;
- }
- public void setMoney()
- {
- Random random = new Random();
- int min = 0, max = 250 ; //soldier's money will be between 125 and 250 Lbs.
- money = random.nextInt(max - min + 1) + min;
- }
- public void setStrength()
- {
- Random random = new Random();
- int min = 0, max = 30 ; //soldier's money will be between 125 and 250 Lbs.
- strength = random.nextInt(max - min + 1) + min;
- }
- public void setEnergy()
- {
- Random random = new Random();
- int min = 0, max = 20 ; //soldier's money will be between 125 and 250 Lbs.
- energy = random.nextInt(max - min + 1) + min;
- }
- public void setName()
- {
- System.out.print("Name your soldier: ");
- Scanner scanner = new Scanner(System.in);
- name = scanner.nextLine();
- }
- public void setAddress()
- {
- address = "Barracks";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement