---
title: "Green Floweri"
description: "import java.util.Vector; public class FloweringWaterLily extends WaterLily { private static final S..."
author: "Duke"
published: "2011-05-25T15:22:41+00:00"
modified: "2011-05-25T15:22:41+00:00"
locale: "ru"
canonical_url: "https://yvision.kz/post/green-floweri-161476"
markdown_url: "https://yvision.kz/post/green-floweri-161476/markdown"
site_name: "Yvision.kz"
---

# Green Floweri

> import java.util.Vector; public class FloweringWaterLily extends WaterLily { private static final S...

import java.util.Vector;

public class FloweringWaterLily extends WaterLily {

private static final String SPECIES = "flowering water lily";

private static final int MIN_AGE_TO_REPRODUCE = 2;

private static final int ENERGY_TO_REPRODUCE = 20;

private static final int STRONG_MIN_ENERGY = 40;

private static final int WEAK_MIN_ENERGY = 20;

private static final String STRONG_IMAGE_NAME = "/flowering-lily-strong.gif";

private static final String WEAK_IMAGE_NAME = "/flowering-lily-weak.gif";

private static final String VERY_WEAK_IMAGE_NAME = "/flowering-lily-very-weak.gif";

private static int nFloweringWaterLilyCreated = 0;

public FloweringWaterLily( int initialRow, int initialColumn, Simulation initialSimulation) {

super( initialRow, initialColumn, initialSimulation, SPECIES + nFloweringWaterLilyCreated);

nFloweringWaterLilyCreated++; }

public String getSpecies() {

return SPECIES; }

public String getImage() {

if (getEnergy() >= STRONG_MIN_ENERGY ) {

return STRONG_IMAGE_NAME;

} else if (getEnergy() >= WEAK_MIN_ENERGY ) {

return WEAK_IMAGE_NAME;

} else {

return VERY_WEAK_IMAGE_NAME;

} }

public void reproduceIfPossible() {

if (getAge() >= MIN_AGE_TO_REPRODUCE && getEnergy() >= ENERGY_TO_REPRODUCE) {

int atRow = getRow(); int atColumn = getColumn(); int lastRow = atRow + 1; int lastColumn = atColumn + 1;

for (int rowToCheck = atRow - 1; rowToCheck = simulation.getFirstRow() && rowToCheck = simulation.getFirstColumn() && colToCheck = STRONG_MIN_ENERGY ) {

return STRONG_IMAGE_NAME;

} else if (getEnergy() >= WEAK_MIN_ENERGY ) {

return WEAK_IMAGE_NAME;

} else {

return VERY_WEAK_IMAGE_NAME;

} }

public void reproduceIfPossible() {

if (getAge() >= MIN_AGE_TO_REPRODUCE) {

int atRow = getRow(); int atColumn = getColumn(); int lastRow = atRow + 1; int lastColumn = atColumn + 1;

for (int rowToCheck = atRow - 1; rowToCheck = ENERGY_TO_REPRODUCE) {

if (rowToCheck >= simulation.getFirstRow() && rowToCheck = simulation.getFirstColumn() && colToCheck <= simulation.getLastColumn() && simulation.getNeighbors( rowToCheck, colToCheck, 0).size() == 0) {

simulation.addLivingBeing(new GreenWaterLily( rowToCheck, colToCheck, simulation)); setEnergy(getEnergy() - ENERGY_TO_REPRODUCE); } } else {

return; } } } } } }

---

Source: [https://yvision.kz/post/green-floweri-161476](https://yvision.kz/post/green-floweri-161476)