Exemple #1
0
        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;
            }
        }
Exemple #2
0
 public override void Breathing(WaterDrop waterDrop)
 {
 }
 public override void Flow(WaterDrop waterDrop)
 {
 }
 public override void Drinking(WaterDrop waterDrop)
 {
 }
Exemple #5
0
 public override void Purification(WaterDrop waterDrop)
 {
     waterDrop.currentState = new RiverState();
 }
 public override void Breathing(WaterDrop waterDrop)
 {
     waterDrop.currentState = new CloudState();
 }
Exemple #7
0
 public override void Flow(WaterDrop waterDrop)
 {
     waterDrop.currentState = new OceanState();
 }
Exemple #8
0
 public override void Drinking(WaterDrop waterDrop)
 {
     waterDrop.currentState = new AnimalState();
 }
Exemple #9
0
 public abstract void Excretion(WaterDrop waterDrop);
Exemple #10
0
 public abstract void Drinking(WaterDrop waterDrop);
Exemple #11
0
 public abstract void Evaporation(WaterDrop waterDrop);
Exemple #12
0
 public abstract void Rainfall(WaterDrop waterDrop);
Exemple #13
0
 public abstract void Breathing(WaterDrop waterDrop);
Exemple #14
0
        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;
                }
            }
        }
Exemple #15
0
 public override void Rainfall(WaterDrop waterDrop)
 {
 }
Exemple #16
0
 public abstract void Flow(WaterDrop waterDrop);
Exemple #17
0
 public override void Evaporation(WaterDrop waterDrop)
 {
     waterDrop.currentState = new CloudState();
 }
Exemple #18
0
 public abstract void Purification(WaterDrop waterDrop);
Exemple #19
0
 public override void Excretion(WaterDrop waterDrop)
 {
 }
Exemple #20
0
 public override void Evaporation(WaterDrop waterDrop)
 {
 }
Exemple #21
0
 public override void Purification(WaterDrop waterDrop)
 {
 }
 public override void Excretion(WaterDrop waterDrop)
 {
     waterDrop.currentState = new SewageState();
 }