When the customer adds more and more additives, the "Notes" line will overflow. How can I modify the code of the "Notes" line to break the line every time it overflows and still display full information?
This is my code:
private static void PrintInvoice(Drink drink)
{
Console.ForegroundColor = ConsoleColor.Green;
// Define a maximum width for each line
const int lineWidth = 46;
// Print the header
Console.WriteLine($"\t\t\t\t\t/{new string('=', lineWidth)}/");
Console.WriteLine($"\t\t\t\t\t/{new string(' ', lineWidth / 2 - 3)}INVOICE{new string(' ', lineWidth / 2 - 4)}/");
Console.WriteLine($"\t\t\t\t\t/{new string('=', lineWidth)}/");
// Print each field dynamically adjusting widths
Console.WriteLine($"\t\t\t\t\t/ Date: {DateTime.Now.ToString("yyyy-MM-dd HH:mm")}");
Console.WriteLine($"\t\t\t\t\t/ Customer: {drink.CustomerName}");
Console.WriteLine($"\t\t\t\t\t/ Drink: {drink.Name}");
Console.WriteLine($"\t\t\t\t\t/ Notes: Added {drink.GetCustomizations()}");
Console.WriteLine($"\t\t\t\t\t/ Total Price: ${drink.Price}");
// Print the footer
Console.WriteLine($"\t\t\t\t\t/{new string('=', lineWidth)}/");
}
This is what it look like: enter image description here

You need to use a loop: