title: How do I display this simple C# app to the console?
body: <pre><code>class Program
  {
      static void Main(string[] args)
      {
          StreamReader sr = new StreamReader("input.txt");
          int lineCount = int.Parse(sr.ReadLine());
  
          List&lt;string&gt; materials = new List&lt;string&gt;();
          List&lt;string&gt; premiumMaterials = new List&lt;string&gt;();
  
          PremiumChocolateFactory premiumChocolate;
          ChocolateFactory chocolate;
  
          while (!sr.EndOfStream)
          {
              string[] line = sr.ReadLine().Split(';');
  
              for (int i = 2; i &lt; line.Length - 1; i++)
              {
                  if (line[line.Length - 1] == "premium")
                  {
                      premiumMaterials.Add(line[i]);
                  }
              }
              for (int i = 2; i &lt; line.Length; i++)
              {
                  if (!line.Contains("premium"))
                  {
                      materials.Add(line[i]);
                  }
              }
  
              premiumChocolate = new PremiumChocolateFactory(line[0], int.Parse(line[1]), premiumMaterials);
              chocolate = new ChocolateFactory(line[0], int.Parse(line[1]), materials);
              Console.WriteLine(premiumChocolate);
              Console.WriteLine(chocolate);
          }
      }
  }
  </code></pre>
  
  <p>3  </p>
  
  <pre><code>dark chocolate;81;cocoa;sugar;cocoa butter;premium  
  milk chocolate;70;cocoa powder;cocoa butter;milk  
  white chocolate;0;sugar;cocoa butter;milk
  </code></pre>
  
  <p>The "input.txt" file contains the above information. The first line is the number of different chocolates, and the rest is like this:<br>
  chocolate type;amount of cocoa;materials(3 of them);and whether the chocolate is premium.  </p>
  
  <p>If it is premium, you have to create a PremiumChocolateFactory object, if not, just a regular ChocolateFactory one. My premium chocolate object displays on the console just fine, but the regular chocolates gets all jumbled up. The PremiumChocolateFactory is inherited from ChocolateFactory. I have overridden the ToString method in my ChocolateFactory class.</p>
  
  <pre><code>return $"Chocolate type: {chocolateType} | Materials: {string.Join(", ", material)} | Cocoa amount: {cocoaAmount}%";
  </code></pre>
  
  <p>I know that the Console.WriteLines shouldn't be inside the while loop but I get an error if they are outside lol.</p>
  
  <p><a href="https://i.stack.imgur.com/DeX1K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DeX1K.png" alt="enter image description here"></a></p>