Autor Beitrag
Firefox69
Hält's aus hier
Beiträge: 12



BeitragVerfasst: So 19.02.12 20:53 
Das ist ein Projekt für die Schule
Lost in Space
Alles ist programmiert nur am Ende verschiebt sich alles nach unten wenn man die eingabe gemacht hat
wie schaff ich das , dass es nicht nahc unten verschiebt ??

Das ist das programm

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lost_in_Space
{
    class Program
    {
        static void Main(string[] args)
        {
            Astro c = new Astro();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.SetCursorPosition(3210);
            Console.WriteLine("Lost In Space");
             Console.SetCursorPosition(2123);
            Console.WriteLine("(Enter drücken um fortzufahren)");
            Console.ReadLine();
            Console.Clear();

            while (true)
            {
                c.Menü();
                int was = 1;
                was = Convert.ToInt32(Console.ReadLine());
                Console.Clear();
                switch (was)
                {
                    case 1:
                        {
                            c.Start();
                            break;
                        }
                    case 2:
                        {
                            c.Help();
                            break;
                        }

                    default:
                        {
                            Console.WriteLine("Ungültige Eingabe");
                            break;
                        }
                }
                c.Ende();
                Console.ReadLine();
                Console.Clear();
            }
        }

    }
}

Moderiert von user profile iconNarses: Beiträge zusammengefasst

& das die Klasse


ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lost_in_Space
{
    class Astro
    {
        public void Menü()
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.SetCursorPosition(301);
            Console.WriteLine("Lost in Space");
            Console.SetCursorPosition(302);
            Console.WriteLine("_____________");
            Console.ResetColor();
            Console.SetCursorPosition(05);
            Console.Write(" -> 1 Drücken zum ");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Write("SPIEL STARTEN");
            Console.ResetColor();
            Console.WriteLine("");
            Console.Write(" -> 2 Drücken zur ");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write("ANLEITUNG STARTEN");
            Console.ResetColor();
            Console.WriteLine("");
            Console.SetCursorPosition(121);
            Console.WriteLine("Bitte geben Sie die gewünschte Ziffer ein und drücken Sie ENTER");
        }
        public void Start()
        {
            int x = new int();
            int y = new int();
            int z = new int();
            int b = 0;


            int[, ,] multiArray;
            multiArray = new int[101101101];
            multiArray[new Random().Next(0100),new Random().Next(0100),new Random().Next(0100)] = 1;

            do
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("Bitte geben Sie die Koordinaten ein, um den Astronaut zu suchen!");
                do
                {
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("X-Koordinate:");
                    x = Convert.ToInt32(Console.ReadLine());
                }
                while (x > 100);
                do
                {
                Console.WriteLine("Y-Koordinate:");
                y = Convert.ToInt32(Console.ReadLine());
                }
                while (y > 100);
                do
                {
                    Console.WriteLine("Z-Koordinate:");
                z = Convert.ToInt32(Console.ReadLine());
                }
                while (z > 100);

                if (multiArray[x, y, z] == 1)
                {
                    Console.WriteLine("Gratulation!");
                    b = 21;
                }
                else
                {
                    Console.WriteLine("Falscher Wert, nochmal!");
                }
                b = b+1;
            }
            while (b < 20);
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Yellow;
                 if (b >= 20) Console.WriteLine("Sorry, du hast verloren. Der Astronaut ist gestorben...");
            else if (b < 5 && b > 1) Console.WriteLine("Sehr Gut !");
            else if (b == 1) Console.WriteLine("Schummler :P");
        }
        public void Help()
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Anleitung des Spiels: ");
            Console.WriteLine("Ein Austronaut der Raumfähre Gaya ist im Weltraum verloren gegangen");
            Console.WriteLine("Das Radar der Raumfähre ist ungenau, du wurdest Auserwählt den Astronaut ");
            Console.WriteLine("zu suchen!");
            Console.WriteLine("Gib einen Wert zwischen 1 und 100 in die X, Y und Z Koordinateneingabe ein, ");
            Console.WriteLine("um den Astronaut zu finden!");
            Console.WriteLine("Vergiss nicht, dass Du nur 20 Versuche hast, ");
            Console.WriteLine("danach ist der Astronaut für immer verloren! VIEL GLÜCK!!!");
        }
        public void Ende()
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.SetCursorPosition(2519);
            Console.WriteLine("(Enter zum Neustart)");
            Console.ResetColor();
        }

    }
}
Moderiert von user profile iconNarses: C#-Tags hinzugefügt