Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Kompletteringsgrejen
- {
- class Program
- {
- static void Main(string[] args)
- {
- // binder orden maxgräns (5).
- string[] OrdVal = new string[5];
- int Ordlägg = 0;
- // loop
- while(true)
- // Menyval
- {
- Console.WriteLine("\n\t**** GISSA ORDET ****");
- Console.WriteLine("\t[1]Mata in ord");
- Console.WriteLine("\t[2]Till spelet");
- Console.WriteLine("\t[3]Avsluta program");
- Console.Beep();
- string menyVal = Console.ReadLine();
- if (menyVal == "1")
- while(Ordlägg < OrdVal.Count()) // Loopas till 5 ord är skrivna.
- {
- Console.Beep ();
- Console.WriteLine("\n\n\t=== MATA IN ORD ===\n\t"); // Koden för ord-inmatning.
- Console.WriteLine("Ord: ");
- OrdVal[Ordlägg] = (Console.ReadLine());
- Console.WriteLine("Ordet är nu tillagt");
- Console.ReadKey();
- Ordlägg++;
- }
- if (menyVal == "2")
- {
- Console.Beep();
- Console.WriteLine("\n\n\t === GISSA ORDET === \n\t"); // koden för att gissa ordet.
- Console.WriteLine("Mata in gissning: ");
- string Figissning = Console.ReadLine();
- foreach (var FiOrd in OrdVal)
- {
- if (FiOrd == Figissning)
- {
- Console.WriteLine("Korrekt gissat.");
- }
- else
- {
- Console.WriteLine("Gissning inkorrekt, försök igen.");
- Console.ReadLine();
- Console.ReadKey();
- }
- }
- }
- if (menyVal == "3")
- {
- break; // Avbryter while loopen, spelet avslutas
- }
- else
- {
- Console.WriteLine("Ogiltligt val!");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement