How to create variables for the status of an order?

Asked

Viewed 302 times

1

How can I create variables to serve as possible order status? After the order already made, I want to create options so that when the attendant type, the order status is changed. The options can be: 1-In transit 2-Canceled 3-Delivered

string Cliente = ""; //Cria a variável Cliente em branco
Console.Write("Cliente: "); //Escreve "Cliente" na tela para o usuário.
Cliente = Console.ReadLine(); //Insere na memória o que foi digitado pelo usuário.

--

List<string> Fila;
Fila = new List<string>(); //Fila criada com 10 elementos 

1 answer

1


Use an Enum:

public enum StatusPedido 
{
   EmTransito = 1,
   Cancelado = 2,
   Entregue = 3
}

So in your class Pedido:

public class Pedido 
{
    ...
    public StatusPedido Status { get; set;}
    ...
}
  • I don’t quite understand.

  • Put in some of your code and I’ll edit it to fit it. For example, how you will receive order status, what technology you are using (ASP.NET, Windows Forms. WPF). Enums are great candidates to represent status, without using magic numbers or strings.

  • String Order = (("Customer:") + Customer + (Environment.Newline + "Product:") + Product + (Environment.Newline + "Size:") + Size + (Environment.Newline + "Quantity") + Quantity); //Add the order to memory

  • string Resp = Console.Readline(); //Reads user response to order confirmation if (Resp == "S") //if the answer is yes, displays success message and asks if you want to add another request { Console.Writeline("Request:" + Request); Queue.Add(Request); Console.Write("Registered Request! Do you want to add another order? (S/N)");

  • You are using a console application then. Edit your question and add the code there, as much as you find relevant. Because instead of storing the request with string in the list, it does not use a Request class. There you can edit the Order status as I showed you in the reply.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.