Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 27 additions & 16 deletions Order.Management/Circle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,42 @@ namespace Order.Management
class Circle : Shape
{
public int circlePrice = 3;
public Circle(int red, int blue, int yellow)
//public Circle(int red, int blue, int yellow)
//{
// Name = "Circle";
// base.Price = circlePrice;
// AdditionalCharge = 1;
// base.NumberOfRedShape = red;
// base.NumberOfBlueShape = blue;
// base.NumberOfYellowShape = yellow;
//}
public Circle()
{
Name = "Circle";
base.Price = circlePrice;
AdditionalCharge = 1;
base.NumberOfRedShape = red;
base.NumberOfBlueShape = blue;
base.NumberOfYellowShape = yellow;
}
public override int Total()
public override int Total(Order order)
{
return RedCirclesTotal() + BlueCirclesTotal() + YellowCirclesTotal();
return ColorCirclesTotal(order, "Red") + ColorCirclesTotal(order, "Blue") + ColorCirclesTotal(order, "Yellow");
}

public int RedCirclesTotal()
public int ColorCirclesTotal(Order order, string color)
{
return (base.NumberOfRedShape * Price);
}
public int BlueCirclesTotal()
{
return (base.NumberOfBlueShape * Price);
}
public int YellowCirclesTotal()
{
return (base.NumberOfYellowShape * Price);
int TotalPrice = order.NumberOfColorShape[color] * Price;
return TotalPrice;
}
//public int RedCirclesTotal()
//{
// return (Order.NumberOfRedShape * Price);
//}
//public int BlueCirclesTotal()
//{
// return (base.NumberOfBlueShape * Price);
//}
//public int YellowCirclesTotal()
//{
// return (base.NumberOfYellowShape * Price);
//}
}
}
62 changes: 15 additions & 47 deletions Order.Management/CuttingListReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,65 +4,33 @@

namespace Order.Management
{
class CuttingListReport : Order
class CuttingListReport : Report
{
public int tableWidth = 20;
public CuttingListReport(string customerName, string customerAddress, string dueDate, List<Shape> shapes)
Order order = new Order();
public CuttingListReport(string customerName, string address, string dueDate, List<Order> shapes)
{
base.CustomerName = customerName;
base.Address = customerAddress;
base.DueDate = dueDate;
base.OrderedBlocks = shapes;
order.CustomerName = customerName;
order.Address = address;
order.DueDate = dueDate;
order.OrderedBlocks = shapes;
}

public override void GenerateReport()
{
Console.WriteLine("\nYour cutting list has been generated: ");
Console.WriteLine(base.ToString());
Console.WriteLine(order.ToString());
generateTable();
}
public void generateTable()
{
PrintLine();
PrintRow(" ", " Qty ");
PrintLine();
PrintRow("Square",base.OrderedBlocks[0].TotalQuantityOfShape().ToString());
PrintRow("Triangle", base.OrderedBlocks[1].TotalQuantityOfShape().ToString());
PrintRow("Circle", base.OrderedBlocks[2].TotalQuantityOfShape().ToString());
PrintLine();
PrintLine(tableWidth);
PrintRow(tableWidth, " ", " Qty ");
PrintLine(tableWidth);
PrintRow(tableWidth, "Square", order.OrderedBlocks[0].TotalQuantityOfShape().ToString());
PrintRow(tableWidth, "Triangle", order.OrderedBlocks[1].TotalQuantityOfShape().ToString());
PrintRow(tableWidth, "Circle", order.OrderedBlocks[2].TotalQuantityOfShape().ToString());
PrintLine(tableWidth);
}
public void PrintLine()
{
Console.WriteLine(new string('-', tableWidth));
}

public void PrintRow(params string[] columns)
{
int width = (tableWidth - columns.Length) / columns.Length;
string row = "|";

foreach (string column in columns)
{
row += AlignCentre(column, width) + "|";
}

Console.WriteLine(row);
}

public string AlignCentre(string text, int width)
{
text = text.Length > width ? text.Substring(0, width - 3) + "..." : text;

if (string.IsNullOrEmpty(text))
{
return new string(' ', width);
}
else
{
return text.PadRight(width - (width - text.Length) / 2).PadLeft(width);
}
}


}
}
78 changes: 27 additions & 51 deletions Order.Management/InvoiceReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

namespace Order.Management
{
class InvoiceReport : Order
class InvoiceReport : Report
{
public int tableWidth = 73;
public InvoiceReport(string customerName, string customerAddress, string dueDate, List<Shape> shapes)
Order order = new Order();
public InvoiceReport(string customerName, string address, string dueDate, List<Order> shapes)
{
base.CustomerName = customerName;
base.Address = customerAddress;
base.DueDate = dueDate;
base.OrderedBlocks = shapes;
order.CustomerName = customerName;
order.Address = address;
order.DueDate = dueDate;
order.OrderedBlocks = shapes;
}

public override void GenerateReport()
Expand All @@ -28,71 +29,46 @@ public override void GenerateReport()

public void RedPaintSurcharge()
{
Console.WriteLine("Red Color Surcharge " + TotalAmountOfRedShapes() + " @ $" + base.OrderedBlocks[0].AdditionalCharge + " ppi = $" + TotalPriceRedPaintSurcharge());
Circle circle = new Circle();
Console.WriteLine("Red Color Surcharge " + TotalAmountOfRedShapes() + " @ $" + circle.AdditionalCharge + " ppi = $" + TotalPriceRedPaintSurcharge());
}

public int TotalAmountOfRedShapes()
{
return base.OrderedBlocks[0].NumberOfRedShape + base.OrderedBlocks[1].NumberOfRedShape +
base.OrderedBlocks[2].NumberOfRedShape;
return order.OrderedBlocks[0].NumberOfColorShape["Red"] + order.OrderedBlocks[1].NumberOfColorShape["Red"] +
order.OrderedBlocks[2].NumberOfColorShape["Red"];
}

public int TotalPriceRedPaintSurcharge()
{
return TotalAmountOfRedShapes() * base.OrderedBlocks[0].AdditionalCharge;
Circle circle = new Circle();
return TotalAmountOfRedShapes() * circle.AdditionalCharge;
}
public void GenerateTable()
{
PrintLine();
PrintRow(" ", " Red ", " Blue ", " Yellow ");
PrintLine();
PrintRow("Square", base.OrderedBlocks[0].NumberOfRedShape.ToString(), base.OrderedBlocks[0].NumberOfBlueShape.ToString(), base.OrderedBlocks[0].NumberOfYellowShape.ToString());
PrintRow("Triangle", base.OrderedBlocks[1].NumberOfRedShape.ToString(), base.OrderedBlocks[1].NumberOfBlueShape.ToString(), base.OrderedBlocks[1].NumberOfYellowShape.ToString());
PrintRow("Circle", base.OrderedBlocks[2].NumberOfRedShape.ToString(), base.OrderedBlocks[2].NumberOfBlueShape.ToString(), base.OrderedBlocks[2].NumberOfYellowShape.ToString());
PrintLine();
PrintLine(tableWidth);
PrintRow(tableWidth, " ", " Red ", " Blue ", " Yellow ");
PrintLine(tableWidth);
PrintRow(tableWidth, "Square", order.OrderedBlocks[0].NumberOfColorShape["Red"].ToString(), order.OrderedBlocks[0].NumberOfColorShape["Blue"].ToString(), order.OrderedBlocks[0].NumberOfColorShape["Yellow"].ToString());
PrintRow(tableWidth, "Triangle", order.OrderedBlocks[1].NumberOfColorShape["Red"].ToString(), order.OrderedBlocks[1].NumberOfColorShape["Blue"].ToString(), order.OrderedBlocks[1].NumberOfColorShape["Yellow"].ToString());
PrintRow(tableWidth, "Circle", order.OrderedBlocks[2].NumberOfColorShape["Red"].ToString(), order.OrderedBlocks[2].NumberOfColorShape["Blue"].ToString(), order.OrderedBlocks[2].NumberOfColorShape["Yellow"].ToString());
PrintLine(tableWidth);
}
//OrderXXXDetails can be merged as one method by passing parameters, e.g.OrderShapeDetails(shape)
public void OrderSquareDetails()
{
Console.WriteLine("\nSquares " + base.OrderedBlocks[0].TotalQuantityOfShape() + " @ $" + base.OrderedBlocks[0].Price + " ppi = $" + base.OrderedBlocks[0].Total());
Square square = new Square();
Console.WriteLine("\nSquares " + order.OrderedBlocks[0].TotalQuantityOfShape() + " @ $" + square.Price + " ppi = $" + square.Total(order.OrderedBlocks[0]));
}
public void OrderTriangleDetails()
{
Console.WriteLine("Triangles " + base.OrderedBlocks[1].TotalQuantityOfShape() + " @ $" + base.OrderedBlocks[1].Price + " ppi = $" + base.OrderedBlocks[1].Total());
Triangle triangle = new Triangle();
Console.WriteLine("Triangles " + order.OrderedBlocks[1].TotalQuantityOfShape() + " @ $" + triangle.Price + " ppi = $" + triangle.Total(order.OrderedBlocks[1]));
}
public void OrderCircleDetails()
{
Console.WriteLine("Circles " + base.OrderedBlocks[2].TotalQuantityOfShape() + " @ $" + base.OrderedBlocks[2].Price + " ppi = $" + base.OrderedBlocks[2].Total());
}
public void PrintLine()
{
Console.WriteLine(new string('-', tableWidth));
}

public void PrintRow(params string[] columns)
{
int width = (tableWidth - columns.Length) / columns.Length;
string row = "|";

foreach (string column in columns)
{
row += AlignCentre(column, width) + "|";
}

Console.WriteLine(row);
}

public string AlignCentre(string text, int width)
{
text = text.Length > width ? text.Substring(0, width - 3) + "..." : text;

if (string.IsNullOrEmpty(text))
{
return new string(' ', width);
}
else
{
return text.PadRight(width - (width - text.Length) / 2).PadLeft(width);
}
Circle circle = new Circle();
Console.WriteLine("Circles " + order.OrderedBlocks[2].TotalQuantityOfShape() + " @ $" + circle.Price + " ppi = $" + circle.Total(order.OrderedBlocks[2]));
}
}
}
16 changes: 12 additions & 4 deletions Order.Management/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@

namespace Order.Management
{
abstract class Order
public class Order
{
public string CustomerName { get; set; }
public string Address { get; set; }
public string DueDate { get; set; }
public int OrderNumber { get; set; }
public List<Shape> OrderedBlocks { get; set; }
public int NumberOfRedShape { get; set; }

public abstract void GenerateReport();
public Dictionary<string, int> NumberOfColorShape{ get; set; }

public string ToString()
public List<Order> OrderedBlocks { get; set; }

public int TotalQuantityOfShape()
{
return NumberOfColorShape["Red"] + NumberOfColorShape["Blue"] + NumberOfColorShape["Yellow"];
}

//override ToString()
public override string ToString()
{
return "\nName: " + CustomerName + " Address: " + Address + " Due Date: " + DueDate + " Order #: " + OrderNumber;
}
Expand Down
61 changes: 15 additions & 46 deletions Order.Management/PaintingReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,33 @@

namespace Order.Management
{
class PaintingReport : Order
class PaintingReport : Report
{
public int tableWidth = 73;
public PaintingReport(string customerName, string customerAddress, string dueDate, List<Shape> shapes)
Order order = new Order();
public PaintingReport(string customerName, string address, string dueDate, List<Order> shapes)
{
base.CustomerName = customerName;
base.Address = customerAddress;
base.DueDate = dueDate;
base.OrderedBlocks = shapes;
order.CustomerName = customerName;
order.Address = address;
order.DueDate = dueDate;
order.OrderedBlocks = shapes;
}
public override void GenerateReport()
{
Console.WriteLine("\nYour painting report has been generated: ");
Console.WriteLine(base.ToString());
Console.WriteLine(order.ToString());
generateTable();
}

public void generateTable()
{
PrintLine();
PrintRow(" ", " Red ", " Blue ", " Yellow ");
PrintLine();
PrintRow("Square", base.OrderedBlocks[0].NumberOfRedShape.ToString(), base.OrderedBlocks[0].NumberOfBlueShape.ToString(), base.OrderedBlocks[0].NumberOfYellowShape.ToString());
PrintRow("Triangle", base.OrderedBlocks[1].NumberOfRedShape.ToString(), base.OrderedBlocks[1].NumberOfBlueShape.ToString(), base.OrderedBlocks[1].NumberOfYellowShape.ToString());
PrintRow("Circle", base.OrderedBlocks[2].NumberOfRedShape.ToString(), base.OrderedBlocks[2].NumberOfBlueShape.ToString(), base.OrderedBlocks[2].NumberOfYellowShape.ToString());
PrintLine();
}

public void PrintLine()
{
Console.WriteLine(new string('-', tableWidth));
}

public void PrintRow(params string[] columns)
{
int width = (tableWidth - columns.Length) / columns.Length;
string row = "|";

foreach (string column in columns)
{
row += AlignCentre(column, width) + "|";
}

Console.WriteLine(row);
}

public string AlignCentre(string text, int width)
{
text = text.Length > width ? text.Substring(0, width - 3) + "..." : text;

if (string.IsNullOrEmpty(text))
{
return new string(' ', width);
}
else
{
return text.PadRight(width - (width - text.Length) / 2).PadLeft(width);
}
PrintLine(tableWidth);
PrintRow(tableWidth, " ", " Red ", " Blue ", " Yellow ");
PrintLine(tableWidth);
PrintRow(tableWidth, "Square", order.OrderedBlocks[0].NumberOfColorShape["Red"].ToString(), order.OrderedBlocks[0].NumberOfColorShape["Blue"].ToString(), order.OrderedBlocks[0].NumberOfColorShape["Yellow"].ToString());
PrintRow(tableWidth, "Triangle", order.OrderedBlocks[1].NumberOfColorShape["Red"].ToString(), order.OrderedBlocks[1].NumberOfColorShape["Blue"].ToString(), order.OrderedBlocks[1].NumberOfColorShape["Yellow"].ToString());
PrintRow(tableWidth, "Circle", order.OrderedBlocks[2].NumberOfColorShape["Red"].ToString(), order.OrderedBlocks[2].NumberOfColorShape["Blue"].ToString(), order.OrderedBlocks[2].NumberOfColorShape["Yellow"].ToString());
PrintLine(tableWidth);
}
}
}
Loading