SupermarketQueue.Find C# (CSharp) Method

Find() public method

public Find ( string name ) : int
name string
return int
    public int Find(string name)
    {
        return this.peopleByName.NumberOfCopies(name);
    }

Usage Example

    static void Main()
    {
        StringBuilder output = new StringBuilder();
        string commandLine = Console.ReadLine();
        SupermarketQueue supermarketQueue = new SupermarketQueue();
        while (commandLine != EndCommand)
        {
            string[] command = commandLine.Split(' ');
            switch (command[0])
            {
                case AppendCommand:
                    supermarketQueue.Append(command[1]);
                    output.AppendLine(OKMessage);
                    break;
                case InsertCommand:
                    if (supermarketQueue.Insert(int.Parse(command[1]), command[2]))
                    {
                        output.AppendLine(OKMessage);
                    }
                    else
                    {
                        output.AppendLine(ErrorMessage);
                    }

                    break;
                case FindCommnad:
                    output.AppendFormat("{0}{1}", supermarketQueue.Find(command[1]), Environment.NewLine);
                    break;
                case ServeCommand:
                    var served = supermarketQueue.Serve(int.Parse(command[1]));
                    if (served != null)
                    {
                        output.AppendLine(string.Join(" ", served));
                    }
                    else
                    {
                        output.AppendLine(ErrorMessage);
                    }

                    break;
            }

            commandLine = Console.ReadLine();
        }

        Console.Write(output);
    }
All Usage Examples Of SupermarketQueue::Find