예제 #1
0
파일: Tests.cs 프로젝트: sutchinger/oom
        public void CanCreatePyramide()
        {
            var x = new Pyramide("Ramses", 1);

            Assert.IsTrue(x.Name == "Ramses");
            Assert.IsTrue(x.Index == 1);
            Assert.IsTrue(x.Typ == "Pyramide");
        }
예제 #2
0
파일: Tests.cs 프로젝트: sutchinger/oom
        public void ArraySortByIndexPossible()
        {
            Pyramide a = new Pyramide("Echnaton", 8);
            Pyramide b = new Pyramide("Ramses", 2);
            Pyramide c = new Pyramide("TutEnchAmun", 1);

            Task_4.IGrab[] array = new Task_4.IGrab[] { a, b, c };
            Array.Sort(array, delegate(Task_4.IGrab x, Task_4.IGrab y) {
                return(x.Index.CompareTo(y.Index));
            });
            Assert.That(array[0].Index == 1);
        }
예제 #3
0
파일: Tests.cs 프로젝트: sutchinger/oom
        public void KeinIndexKleinerNull()
        {
            var x = new Pyramide("Hans", -1);

            Assert.True(x.Index > 0);
            var y = new ErdGrab("Hans", -1);

            Assert.True(y.Index > 0);
            var z = new UrnenGrab("Hans", -1);

            Assert.True(z.Index > 0);
        }
예제 #4
0
파일: Tests.cs 프로젝트: sutchinger/oom
        ///Console Out Test!!!
        public void SklavenKommen()
        {
            var x = new Pyramide("Ramses", 1);

            using (StreamWriter writer = new StreamWriter(Path.GetTempPath() + "\\test.txt"))
            {
                Console.SetOut(writer);
                x.MachInschrift();
            }
            string result = File.ReadAllText(Path.GetTempPath() + "\\test.txt");

            Assert.IsTrue(result.StartsWith("Sklaven"));
        }
예제 #5
0
        public static void Run()
        {
            Pyramide a = new Pyramide("Ramses", 1);
            Pyramide b = new Pyramide("TutEnchAmun", 2);
            Pyramide c = new Pyramide("Echnaton", 8);
            ErdGrab  d = new ErdGrab("Mayer", 4);
            ErdGrab  e = new ErdGrab("Suchy", 12);
            ErdGrab  f = new ErdGrab("Sandler", 7);


            IGrab[] array = new IGrab[] { a, b, c, d, e, f };

            /// Array ausgeben
            /// Array sortieren
            //array.OrderBy(grab=>grab.Name)
            Array.Sort(array, delegate(IGrab x, IGrab y) {
                return(x.Index.CompareTo(y.Index));
            });
            foreach (var x in array)
            {
                WriteLine($"{x.Name} auf Nummer {x.Index} in einem Typ {x.Typ}; zum Inschrift erstellen: ");
                x.MachInschrift();
                WriteLine("\n");
            }

            /// Serialisieren / Deserialisieren
            string GrabListe1 = JsonConvert.SerializeObject(array);

            WriteLine("\nGrabliste1:\n" + GrabListe1);
            //File.Create(@"C:\gkkdfu\test.txt");
            try
            {
                File.WriteAllText(Path.GetTempPath() + "\\test.txt", GrabListe1);
            }
            catch (UnauthorizedAccessException p)
            {
                WriteLine(p.Message);
            }
            string GrabListe2 = File.ReadAllText(Path.GetTempPath() + "\\test.txt");

            WriteLine("\nGrabliste 2:\n" + GrabListe2);



            string P1 = JsonConvert.SerializeObject(a);

            WriteLine("\n****" + P1 + "***\n");
            Pyramide z = JsonConvert.DeserializeObject <Pyramide>(P1);

            WriteLine($"{z.Name} liegt auf Nummer {z.Index} in einem Typ {z.Typ}");
        }
예제 #6
0
        static void Main(string[] args)
        {
            do
            {
                try
                {
                    Circle     circle    = new Circle();
                    Cube       cube      = new Cube();
                    ITransform transform = circle;
                    Report(circle);
                    Report(cube);
                    Report(transform);

                    Pyramide pyramide = new Pyramide {
                        B = 2, H = 3
                    };
                    Report(pyramide);
                    pyramide.Transform(2);
                    Report(pyramide);

                    ITransform[] transforms = new ITransform[3];
                    transforms[0] = new Cube {
                        Rib = 2
                    };
                    transforms[1] = new Circle {
                        Rad = 2
                    };
                    transforms[2] = new Cylinder {
                        H = 2, R = 3
                    };

                    Array.ForEach(transforms, Report);
                    Array.ForEach(transforms, transform1 => transform1.Transform(2));
                    Array.ForEach(transforms, Report);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                Console.WriteLine("Press Esc to exit or another button to continue");
            } while (Console.ReadKey().Key != ConsoleKey.Escape);
        }
예제 #7
0
파일: Program.cs 프로젝트: sutchinger/oom
        static void Main(string[] args)
        {
            var rand   = new Random();
            var pCount = 0;
            var eCount = 1000;
            var uCount = 1000000;

            GrabArrayErstellen.Run();
            ManuellesGrab.Run();


            WriteLine("*****************************\n");
            WriteLine("UNERWARTETER PEST AUSBRUCH!!!\n");
            WriteLine("*****************************\n");
            var pSource = new Subject <Pyramide>();
            var eSource = new Subject <ErdGrab>();
            var uSource = new Subject <UrnenGrab>();

            pSource
            .Subscribe(x =>
            {
                WriteLine($"Index: {x.Index}");
                x.MachInschrift();
                WriteLine();
            })
            ;



            eSource
            .Subscribe(x =>
            {
                WriteLine($"Index: {x.Index}");
                x.MachInschrift();
                WriteLine();
            })
            ;

            uSource
            .Subscribe(x =>
            {
                WriteLine($"Index: {x.Index}");
                x.MachInschrift();
                WriteLine();
            })
            ;

            var pTask = Task.Run(() =>
            {
                while (true)
                {
                    Task.Delay(TimeSpan.FromSeconds(5.0 + rand.Next(5))).Wait();
                    pCount++;
                    Console.WriteLine("*******ANOTHER KING GONE******");
                    Pyramide x = new Pyramide(pCount);
                    pSource.OnNext(x);
                    //return x;
                }
            });
            var eTask = Task.Run(() =>
            {
                while (true)
                {
                    Task.Delay(TimeSpan.FromSeconds(2.0 + rand.Next(4))).Wait();
                    eCount++;
                    Console.WriteLine("R.I.P");
                    ErdGrab e = new ErdGrab(eCount);
                    eSource.OnNext(e);
                    //return x;
                }
            });
            var uTask = Task.Run(() =>
            {
                while (true)
                {
                    Task.Delay(TimeSpan.FromSeconds(1.0 + rand.Next(1))).Wait();
                    uCount++;
                    Console.WriteLine("some scum got burnt");
                    UrnenGrab x = new UrnenGrab(uCount);
                    uSource.OnNext(x);
                    //return x;
                }
            });

            Wissenschaftler.Run();



            //WriteLine("Anykey");
            ReadKey();
        }
예제 #8
0
파일: Tests.cs 프로젝트: sutchinger/oom
        public void PyramideNoName()
        {
            var y = new Pyramide("", 1);

            Assert.False(y.Name == "");
        }