<commit_before>package com.lockness.program;

import java.io.File;
import java.util.List;
import java.util.Scanner;

import com.lockness.kitchen.Cookbook;
import com.lockness.kitchen.Recipe;
import com.lockness.util.InputParser;

/**
 * @author <NAME>
 * @author <NAME>
 */
public class ProgramMain {

	Cookbook cookbook;

	public void programStart() {
		this.initializeProgram();
		this.welcome();
		this.userInterface();
	}

	void initializeProgram(){
		this.cookbook = new Cookbook();

		File recipeFolder = new File("Recipe");
		File[] listOfRecipes = recipeFolder.listFiles();

		for(int i = 0; i < listOfRecipes.length; i++) {
			Recipe recipe = InputParser.parseRCP(listOfRecipes[i].getName());
			cookbook.addRecipe(recipe);
		}

	}

	void welcome() {
		System.out.println("//--------------------------\\\\");
		System.out.println("|| Welcome to CollegeCooks! ||");
		System.out.println("\\\\--------------------------//\n");
	}

	void userInterface() {
		Scanner scanner = new Scanner(System.in);		
		boolean loop = true;

		while (loop) {
			System.out.print("| ");
			String userInput = scanner.nextLine();
			if (userInput.equalsIgnoreCase("Search")) {
				System.out.println("Enter a keyword");
				String keyword = scanner.nextLine();
				List<Recipe> foundRecipes = cookbook.searchRecipe(keyword);

				System.out.println("0 - Back");
				for (int i = 0; i < foundRecipes.size(); i++) {
					System.out.println((i + 1) + " - " + foundRecipes.get(i).getName());
				}
				int userSelection = 0;
				while (true) {
					try {
						userSelection = scanner.nextInt();
						scanner.nextLine();
						break;
					} catch (Exception e) {
						System.out.println("Please enter an integer.");
					}
				}
				if (userSelection == 0) {
					//insert possible boolean
				} else {
					while(true) {
						if (userSelection > 0 && userSelection <= foundRecipes.size()) {
							Recipe userRecipe = foundRecipes.get(userSelection - 1);
							System.out.println(userRecipe.toString());
							break;
						} else {
							System.out.println("Not a valid selection. Try again.");
							userSelection = scanner.nextInt(); //Find safer way to get int from user.
							scanner.nextLine();
						}
					}
				}
			} else if (userInput.equalsIgnoreCase("list") || userInput.equalsIgnoreCase("ls")) {
				cookbook.listRecipes();
<<<<<<< HEAD
=======
			} else if (userInput.equalsIgnoreCase("add")) {
				String recipeName = InputParser.makeRCP(scanner);
				cookbook.addRecipe(InputParser.parseRCP(recipeName));
				System.out.println("Added " + recipeName + '\n');
>>>>>>> UIWriteToFile
			} else if (userInput.equalsIgnoreCase("help") || userInput.equalsIgnoreCase("h")) {
				System.out.println("Options: ");
				System.out.println("   Search\tFind a Recipe");
				System.out.println("   List\tList Recipes");<commit_msg>Fixing last commit. I left something in by accident.<commit_after>package com.lockness.program;

import java.io.File;
import java.util.List;
import java.util.Scanner;

import com.lockness.kitchen.Cookbook;
import com.lockness.kitchen.Recipe;
import com.lockness.util.InputParser;

/**
 * @author <NAME>
 * @author <NAME>
 */
public class ProgramMain {

	Cookbook cookbook;

	public void programStart() {
		this.initializeProgram();
		this.welcome();
		this.userInterface();
	}

	void initializeProgram(){
		this.cookbook = new Cookbook();

		File recipeFolder = new File("Recipe");
		File[] listOfRecipes = recipeFolder.listFiles();

		for(int i = 0; i < listOfRecipes.length; i++) {
			Recipe recipe = InputParser.parseRCP(listOfRecipes[i].getName());
			cookbook.addRecipe(recipe);
		}

	}

	void welcome() {
		System.out.println("//--------------------------\\\\");
		System.out.println("|| Welcome to CollegeCooks! ||");
		System.out.println("\\\\--------------------------//\n");
	}

	void userInterface() {
		Scanner scanner = new Scanner(System.in);		
		boolean loop = true;

		while (loop) {
			System.out.print("| ");
			String userInput = scanner.nextLine();
			if (userInput.equalsIgnoreCase("Search")) {
				System.out.println("Enter a keyword");
				String keyword = scanner.nextLine();
				List<Recipe> foundRecipes = cookbook.searchRecipe(keyword);

				System.out.println("0 - Back");
				for (int i = 0; i < foundRecipes.size(); i++) {
					System.out.println((i + 1) + " - " + foundRecipes.get(i).getName());
				}
				int userSelection = 0;
				while (true) {
					try {
						userSelection = scanner.nextInt();
						scanner.nextLine();
						break;
					} catch (Exception e) {
						System.out.println("Please enter an integer.");
					}
				}
				if (userSelection == 0) {
					//insert possible boolean
				} else {
					while(true) {
						if (userSelection > 0 && userSelection <= foundRecipes.size()) {
							Recipe userRecipe = foundRecipes.get(userSelection - 1);
							System.out.println(userRecipe.toString());
							break;
						} else {
							System.out.println("Not a valid selection. Try again.");
							userSelection = scanner.nextInt(); //Find safer way to get int from user.
							scanner.nextLine();
						}
					}
				}
			} else if (userInput.equalsIgnoreCase("list") || userInput.equalsIgnoreCase("ls")) {
				cookbook.listRecipes();
			} else if (userInput.equalsIgnoreCase("help") || userInput.equalsIgnoreCase("h")) {
				System.out.println("Options: ");
				System.out.println("   Search\tFind a Recipe");
				System.out.println("   List\tList Recipes");
{'fraction_non_alphanumeric': 0.1748573532118535, 'fraction_numerical': 0.0029449659488312166, 'mean_word_length': 3.0014727540500736, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 18, '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': '2966881', 'n_tokens_mistral': 2100, 'n_tokens_neox': 1680, 'n_words': 355}