public override void Rainfall(WaterDrop waterDrop) { Random rnd = new Random(); int nextState = rnd.Next(0, 3); switch (nextState) { case 0: waterDrop.currentState = new PlantState(); break; case 1: waterDrop.currentState = new WellState(); break; case 2: waterDrop.currentState = new RiverState(); break; } }
public override void Breathing(WaterDrop waterDrop) { }
public override void Flow(WaterDrop waterDrop) { }
public override void Drinking(WaterDrop waterDrop) { }
public override void Purification(WaterDrop waterDrop) { waterDrop.currentState = new RiverState(); }
public override void Breathing(WaterDrop waterDrop) { waterDrop.currentState = new CloudState(); }
public override void Flow(WaterDrop waterDrop) { waterDrop.currentState = new OceanState(); }
public override void Drinking(WaterDrop waterDrop) { waterDrop.currentState = new AnimalState(); }
public abstract void Excretion(WaterDrop waterDrop);
public abstract void Drinking(WaterDrop waterDrop);
public abstract void Evaporation(WaterDrop waterDrop);
public abstract void Rainfall(WaterDrop waterDrop);
public abstract void Breathing(WaterDrop waterDrop);
static void Main(string[] args) { WaterDrop wd = new WaterDrop(); for (int i = 0; i <= 10; i++) { Console.WriteLine(wd.currentState.Info()); switch (wd.currentState.Info()) { case "Cloud": wd.Rainfall(); break; case "Plant": wd.Breathing(); break; case "Well": wd.Drinking(); break; case "Sewage": wd.Purification(); break; case "Ocean": wd.Evaporation(); break; case "River": Random rndR = new Random(); int nextStateR = rndR.Next(0, 3); switch (nextStateR) { case 0: wd.Evaporation(); break; case 1: wd.Flow(); break; case 2: wd.Drinking(); break; } break; case "Human": Random rndHuman = new Random(); int nextStateHuman = rndHuman.Next(0, 2); switch (nextStateHuman) { case 0: wd.Breathing(); break; case 1: wd.Excretion(); break; } break; case "Animal": Random rndAnimal = new Random(); int nextStateAnimal = rndAnimal.Next(0, 2); switch (nextStateAnimal) { case 0: wd.Breathing(); break; case 1: wd.Excretion(); break; } break; } } }
public override void Rainfall(WaterDrop waterDrop) { }
public abstract void Flow(WaterDrop waterDrop);
public override void Evaporation(WaterDrop waterDrop) { waterDrop.currentState = new CloudState(); }
public abstract void Purification(WaterDrop waterDrop);
public override void Excretion(WaterDrop waterDrop) { }
public override void Evaporation(WaterDrop waterDrop) { }
public override void Purification(WaterDrop waterDrop) { }
public override void Excretion(WaterDrop waterDrop) { waterDrop.currentState = new SewageState(); }