Пример #1
0
  public static void main(String[] args) {
    //		create a world
    World world = new World(numFarmsInWorld);

    //		initialize both farms
    Farm farm1 = world.getAFarm(0);

    //		create the FarmObjects
    Cow cow = new Cow("cow ");
    FlyingCow fCow = new FlyingCow("fcow");
    NocturnalCow nCow = new NocturnalCow("ncow");
    Grass grass = new Grass();
    PoisonedGrass pGrass = new PoisonedGrass();

    //		initialize fObjects that contains all farm animals on a farm
    FarmObject[] fObjects = {cow, fCow, nCow, grass, pGrass};

    //		populate both farms
    farm1.populateFarm(FARM_ROWS, FARM_COLS, fObjects);

    //		print initial farm states
    System.out.println("Initial State of Farm1: ");
    System.out.println("------------------------");
    printFarmState(farm1.getFarmGrid());
    System.out.println("------------------------");

    world.simulateWorld(HOURS);

    //		print final farm states after HOURS hours
    System.out.println("Final State of Farm1: ");
    System.out.println("------------------------");
    printFarmState(farm1.getFarmGrid());
    System.out.println("------------------------");
  }