<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ShoppingApp
{
    class Program
    {
        static string[] ReadCatalogFromFile()
        {
            string[] catalog = new string[200];
            int current = 0;

            StreamReader reader = new StreamReader("catalog.txt");
            string line;
            while ((line = reader.ReadLine()) != null)
            {
                catalog[current] = line;
                
                current = current + 1;
                if (current >= 200)
                    break;
            }

            return catalog;
        }

        static bool IsProductInCatalog(string product, string[] catalog)
        {
            foreach (string productInCatalog in catalog)
            {
                if (product == productInCatalog)
                    return true;
            }
            return false;
        }

        static void Main(string[] args)
        {
            Console.WriteLine("*** Hello! Welcome to the shopping application. ***");

            string[] catalog = ReadCatalogFromFile();

            string[] cart = new string[5];
            
            int productsAdded = 0;
            while (productsAdded < cart.Length)
            {
                Console.Write("Enter a product: ");
                string product = Console.ReadLine();
                if (!IsProductInCatalog(product, catalog))
                {
                    Console.WriteLine("Sorry, the product \"{0}\" is not in the catalog. Try another product.", product);
                }
                else
                {
                    cart[productsAdded] = product;
                    productsAdded = productsAdded + 1;
                    Console.WriteLine("$$$ \"{0}\" has been added to your shopping cart.", product);
                }
            }

            Console.WriteLine("*** You're ready to check out! Here are the products in your shopping cart: ***");
            foreach (string product in cart)
            {
                Console.WriteLine(product);
            }
        }
    }
}
<commit_msg>Revised the solution to use ReadAllLines like in the 2.0 document<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ShoppingApp
{
    class Program
    {
        static bool IsProductInCatalog(string product, string[] catalog)
        {
            foreach (string productInCatalog in catalog)
            {
                if (product == productInCatalog)
                    return true;
            }
            return false;
        }

        static void Main(string[] args)
        {
            Console.WriteLine("*** Hello! Welcome to the shopping application. ***");

            string[] catalog = File.ReadAllLines("catalog.txt");

            string[] cart = new string[5];
            
            int productsAdded = 0;
            while (productsAdded < cart.Length)
            {
                Console.Write("Enter a product: ");
                string product = Console.ReadLine();
                if (!IsProductInCatalog(product, catalog))
                {
                    Console.WriteLine("Sorry, the product \"{0}\" is not in the catalog. Try another product.", product);
                }
                else
                {
                    cart[productsAdded] = product;
                    productsAdded = productsAdded + 1;
                    Console.WriteLine("$$$ \"{0}\" has been added to your shopping cart.", product);
                }
            }

            Console.WriteLine("*** You're ready to check out! Here are the products in your shopping cart: ***");
            foreach (string product in cart)
            {
                Console.WriteLine(product);
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.0955510616784631, 'fraction_numerical': 0.005055611729019211, 'mean_word_length': 1.4098660170523751, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6190198', 'n_tokens_mistral': 939, 'n_tokens_neox': 893, 'n_words': 273}