C#C
C#2y ago
js

✅ checking console input for certain letters

public override void Select()
{
    Console.WriteLine("Please enter the customer's name.");
    string CustomerName = Console.ReadLine();
    Console.WriteLine("Is this order for delivery? ( Y / N )");
    string forDelivery = Console.ReadLine();
    void CheckInput(string input)
    {
        if (input != "Y" || input != "N")
        {
            Console.WriteLine("Invalid input! (Y or N)");
            Console.WriteLine("Is this order for delivery? ( Y / N )");
            forDelivery = Console.ReadLine();
            CheckInput(forDelivery);
        }
        else if (input == "N" || input == "Y")
        {
            return;
        }
    }
    CheckInput(forDelivery);

    Order order = new Order(CustomerName, forDelivery);
    _manager.AddOrder(order);
}
image.png
Was this page helpful?