maxo10

Loops Assignment

Jan 18th, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.86 KB | None | 0 0
  1. // CLASS 1:
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace safeprojectname
  9. {
  10.     class Program
  11.     {
  12.         static void Main()
  13.         {
  14.  
  15.             string[] loops = Xvalues.loops;
  16.             Dictionary<int, string> dicto = Xvalues.DerpCats;
  17.             List<int> DerpList = Xvalues.SirList;
  18.  
  19.             //takes the elements one for one and sets them as 'element' variable, taken from the 'loops' string.
  20.             foreach (string element in loops)
  21.             {
  22.                 Console.WriteLine(element);
  23.                 System.Threading.Thread.Sleep(1500);
  24.                 //does the case of the used element,
  25.                 switch (element)
  26.                 {
  27.                     case "ForEach loop:":
  28.                         {
  29.                             Console.WriteLine("This whole structure of writing is a ForEach loop with a switch!");
  30.                             break;
  31.                         }
  32.                     case "For loop:":
  33.                         {
  34.                             //checks how many elements the string has.
  35.                             for (int i = 0; i < loops.Length; i++)
  36.                             {
  37.                                 //Console.WriteLine(loops[i]);
  38.                                 Console.WriteLine(dicto[i]);
  39.                                 Console.WriteLine(DerpList[i]);
  40.                                 System.Threading.Thread.Sleep(1500);
  41.                             }
  42.                             break;
  43.                         }
  44.                     case "While loop:":
  45.                         {
  46.                             //easy, but the many letters are too awesome! xD
  47.                             int IsWhileExecutedTheStringLength = 0;
  48.                             while (IsWhileExecutedTheStringLength < loops.Length)
  49.                             {
  50.                                 //Console.WriteLine(loops[IsWhileExecutedTheStringLength]);
  51.                                 Console.WriteLine(dicto[IsWhileExecutedTheStringLength]);
  52.                                 Console.WriteLine(DerpList[IsWhileExecutedTheStringLength]);
  53.                                 IsWhileExecutedTheStringLength++;
  54.                             }
  55.                             break;
  56.                         }
  57.                     case "Do While loop:":
  58.                         {
  59.                             int TheDoWhileLoop = 0;
  60.                             do
  61.                             {
  62.                                 //Console.WriteLine(loops[TheDoWhileLoop]);
  63.                                 Console.WriteLine(dicto[TheDoWhileLoop]);
  64.                                 Console.WriteLine(DerpList[TheDoWhileLoop]);
  65.                                 TheDoWhileLoop++;
  66.                             } while (TheDoWhileLoop < loops.Length);
  67.                             break;
  68.                         }
  69.                 }
  70.  
  71.                 Console.WriteLine();
  72.                 System.Threading.Thread.Sleep(1500);
  73.             }
  74.  
  75.             Console.WriteLine("Done!");
  76.             Console.ReadKey();
  77.  
  78.         }
  79.     }
  80. }
  81.  
  82. // CLASS 2:
  83. using System;
  84. using System.Collections.Generic;
  85. using System.Linq;
  86. using System.Text;
  87. using System.Threading.Tasks;
  88.  
  89. namespace safeprojectname
  90. {
  91.     public class Xvalues
  92.     {
  93.         public static string[] loops = { "ForEach loop:", "For loop:", "While loop:", "Do While loop:" };
  94.         public static Dictionary<int, string> DerpCats = new Dictionary<int, string>()
  95.             {
  96.                 {0, "hans"},
  97.                 {1, "greta" },
  98.                 {2, "Gruber" },
  99.                 {3, "SirCat" }
  100.             };
  101.         public static List<int> SirList = new List<int>()
  102.             {
  103.                 {0},
  104.                 {1},
  105.                 {2},
  106.                 {3}
  107.             };
  108.      }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment