public class Vehicle // a generic military vehicle used as a base class for the various subtypes that will be { // used in the Wargame program. Although this class is generic, it will be created with // some specific values so that we can obtain a battle utility. // the following instance data will be inherited by all subclasses protected String type; // the name of the vehicle protected boolean heavilyArmored; // is the vehicle heavily armored (can withstand some artillery shells?) protected int capacity; // how many personnel will this vehicle carry? protected int speed; // speed is used to determine the distance the vehicle can travel protected int armament; // represents the fire power of the vehicle public Vehicle() // no arg constructor, calls the 1-arg constructor { this("unknown"); } public Vehicle(String t) // initialize instance data based on "skeleton" of a Vehicle { type=t; heavilyArmored=false; capacity=1; speed=0; armament=0; } // accessors public String getType() { return type; } public boolean getHeavilyArmored() { return heavilyArmored; } public int getCapcity() { return capacity; } public int getSpeed() { return speed; } public int getArmament() { return armament; } // define a toString to be inherited public String toString() { return type + " is heavily armored " + heavilyArmored + ", has capacity of " + capacity + ", speed of " + speed + " and armament value of " + armament; } // define a getBattleUtility method to be inherited so that all Vehicle types can determine how useful they will be // based on a scenario, this method always returns a default of -100 public int getBattleUtility(boolean night, boolean roughTerrain, boolean needGroundSupport, boolean needHeavyArms, boolean antiAircraftGuns, boolean equipment, int distance) { return -100; } }