using System;
using System.Text;
using System.Collections;
namespace OrdersParser{
/// <summary>
/// This class describes an order record.
/// </summary>
public class Order
{
private string number;
private DateTime added = DateTime.Now;
private Client client;
private ArrayList items = new ArrayList();
private decimal total;
public Order()
{
}
public string Number
{
get { return number; }
set { number = value; }
}
public DateTime Added
{
get { return added; }
set { added = value; }
}
public Client Client
{
get { return client; }
set { client = value; }
}
public ArrayList Items
{
get { return items; }
}
public decimal Total
{
get { return total; }
set { total = value; }
}
public void SetClient(Client client)
{
this.client = client;
}
public void AddItem(Item item)
{
items.Add(item);
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("\nOrder #")
.Append(number)
.Append(" of ")
.Append(added)
.Append("\nClient: ")
.Append(client.ToString())
.Append("\nOrdered items:");
foreach(Item item in items)
{
sb.Append("\n")
.Append(item.ToString());
}
sb.Append("\nOrder total: ")
.Append(total);
return sb.ToString();
}
}
}
|