<commit_before>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package poulproj07;

import java.util.Scanner;

/**
 *
 * @author marsh
 */
public class Poulproj07 {

    static Queue<String> queue;
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        System.out.println("welcome to the queue driver program");
        Scanner keyboard = new Scanner(System.in);
        queue = new Queue<>();
        menu(keyboard);
    }
    
    /*
     * this function accepts a scanner which should already be directed to the 
     * standard input device it will output a menu and then call the 
     * appropraiate functions including itself
     */
    public static void menu(Scanner keyboard)
    {
        int choice;
        System.out.println("\nmenu");
        System.out.println("1) enqueue");
        System.out.println("2) peek");
        System.out.println("3) dequeue");
        System.out.println("4) is empty");
        System.out.println("5) exit");
        choice = getValidMenuInt(keyboard);
        System.out.println("");
        
        switch(choice)
        {
            case 1:
                System.out.println("please enter a string");
                keyboard.reset();
                String temp = keyboard.nextLine();
                queue.enqueue(temp);
                menu(keyboard);
                break;
            case 2:
                try
                {
                    System.out.println(queue.peek());
                }
                catch(Exception e)
                {
                    System.out.println(e);
                }
                menu(keyboard);
                break;
            case 3:
                try
                {
                    System.out.println(queue.dequeue());
                }
                catch(Exception e)
                {
                    System.out.println(e);
                }
                menu(keyboard);
                break;
            case 4:
                System.out.println(queue.isEmpty());
                menu(keyboard);
                break;
            case 5:
                //fallout of the menu
                break;
        } 
    }
    final static int MINMENUCHOICE = 1;
    final static int MAXMENUCHOICE = 5;
    /*
     * this function will prompt the user to enter a valid menu integer
     * and will return this value will reprompt as many times as necessary
     * the parameter is an initialized instance of a scanner
     */
    public static int getValidMenuInt(Scanner keyboard)
    {
        try
        {
            int value;
            System.out.println("please enter your choice:");
            value = keyboard.nextInt();
            keyboard.nextLine();//purges \n from the stream
            if((value > MAXMENUCHOICE) || (value < MINMENUCHOICE))
            {
                return getValidMenuInt(keyboard);
            }
            //else
            //base case
            return value;
        }
        catch(Exception e)
        {
            return getValidMenuInt(keyboard);
        }
    }
}
<commit_msg>finished project 07<commit_after>/*
 * this file contains the driver program for the queue class
 * by <NAME> 10/22/2013
 */
package poulproj07;

import java.util.Scanner;

/*
 * the main class designed to hold the driver program, main, the menu and the 
 * funticions that the menu needs to verify user input
 */
public class Poulproj07 {

    static Queue<String> queue;
    /**
     * outputs a greeting to the user initializes a queue and Scanner to the
     * keyboard and then calls the menu
     */
    public static void main(String[] args)
    {
        System.out.println("welcome to the queue driver program");
        Scanner keyboard = new Scanner(System.in);
        queue = new Queue<>();
        menu(keyboard);
    }
    
    /*
     * this function accepts a scanner which should already be directed to the 
     * standard input device it will output a menu and then call the 
     * appropraiate functions including itself
     */
    public static void menu(Scanner keyboard)
    {
        int choice;
        System.out.println("\nmenu");
        System.out.println("1) enqueue");
        System.out.println("2) peek");
        System.out.println("3) dequeue");
        System.out.println("4) is empty");
        System.out.println("5) exit");
        choice = getValidMenuInt(keyboard);
        System.out.println("");
        
        switch(choice)
        {
            case 1:
                System.out.println("please enter a string");
                keyboard.reset();
                String temp = keyboard.nextLine();
                queue.enqueue(temp);
                menu(keyboard);
                break;
            case 2:
                try
                {
                    System.out.println(queue.peek());
                }
                catch(Exception e)
                {
                    System.out.println(e);
                }
                menu(keyboard);
                break;
            case 3:
                try
                {
                    System.out.println(queue.dequeue());
                }
                catch(Exception e)
                {
                    System.out.println(e);
                }
                menu(keyboard);
                break;
            case 4:
                System.out.println(queue.isEmpty());
                menu(keyboard);
                break;
            case 5:
                //fallout of the menu
                break;
        } 
    }
    final static int MINMENUCHOICE = 1;
    final static int MAXMENUCHOICE = 5;
    /*
     * this function will prompt the user to enter a valid menu integer
     * and will return this value will reprompt as many times as necessary
     * the parameter is an initialized instance of a scanner
     */
    public static int getValidMenuInt(Scanner keyboard)
    {
        try
        {
            int value;
            System.out.println("please enter your choice:");
            value = keyboard.nextInt();
            keyboard.nextLine();//purges \n from the stream
            if((value > MAXMENUCHOICE) || (value < MINMENUCHOICE))
            {
                return getValidMenuInt(keyboard);
            }
            //else
            //base case
            return value;
        }
        catch(Exception e)
        {
            return getValidMenuInt(keyboard);
        }
    }
}

{'fraction_non_alphanumeric': 0.08964569334147832, 'fraction_numerical': 0.006414172266340868, 'mean_word_length': 1.3498385360602798, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '2966097', 'n_tokens_mistral': 1747, 'n_tokens_neox': 1620, 'n_words': 481}