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
20 changes: 12 additions & 8 deletions Order.Management/Circle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,35 @@ namespace Order.Management
class Circle : Shape
{
public int circlePrice = 3;
public Circle(int red, int blue, int yellow)

public Circle(int numberOfRedCircles, int numberOfBlueCircles, int numberOfYellowCircles)
{
Name = "Circle";
base.Price = circlePrice;
Price = circlePrice;
AdditionalCharge = 1;
base.NumberOfRedShape = red;
base.NumberOfBlueShape = blue;
base.NumberOfYellowShape = yellow;
NumberOfRedShape = numberOfRedCircles;
NumberOfBlueShape = numberOfBlueCircles;
NumberOfYellowShape = numberOfYellowCircles;
}

public override int Total()
{
return RedCirclesTotal() + BlueCirclesTotal() + YellowCirclesTotal();
}

public int RedCirclesTotal()
{
return (base.NumberOfRedShape * Price);
return (NumberOfRedShape * Price);
}

public int BlueCirclesTotal()
{
return (base.NumberOfBlueShape * Price);
return (NumberOfBlueShape * Price);
}

public int YellowCirclesTotal()
{
return (base.NumberOfYellowShape * Price);
return (NumberOfYellowShape * Price);
}
}
}
57 changes: 13 additions & 44 deletions Order.Management/CuttingListReport.cs
Original file line number Diff line number Diff line change
@@ -1,68 +1,37 @@
using System;
using System.Collections.Generic;
using System.Text;

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

public override void GenerateReport()
{
Console.WriteLine("\nYour cutting list has been generated: ");
Console.WriteLine(base.ToString());
generateTable();
Console.WriteLine(ReportSummaryHeader());
GenerateReportDetail(" ", " Qty ");
}
public void generateTable()

public new void GenerateReportDetail(params string[] reportDetailColumns)
{
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());
PrintRow(reportDetailColumns);
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)
foreach (var orderedblock in OrderedBlocks)
{
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);
PrintRow(orderedblock.Name, orderedblock.TotalQuantityOfShape().ToString());
}
PrintLine();
}


}
}
100 changes: 36 additions & 64 deletions Order.Management/InvoiceReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,93 +6,65 @@ namespace Order.Management
{
class InvoiceReport : Order
{
public int tableWidth = 73;
public InvoiceReport(string customerName, string customerAddress, string dueDate, List<Shape> shapes)
{
base.CustomerName = customerName;
base.Address = customerAddress;
base.DueDate = dueDate;
base.OrderedBlocks = shapes;
CustomerName = customerName;
Address = customerAddress;
DueDate = dueDate;
OrderedBlocks = shapes;
ReportTableWidth = 73;
}

public override void GenerateReport()
{
Console.WriteLine("\nYour invoice report has been generated: ");
Console.WriteLine(base.ToString());
GenerateTable();
OrderSquareDetails();
OrderTriangleDetails();
OrderCircleDetails();
Console.WriteLine(ReportSummaryHeader());
GenerateReportDetail(" ", " Red ", " Blue ", " Yellow ");

foreach (var orderedBlock in OrderedBlocks)
{
Console.WriteLine(string.Format("\n{0} {1} @ ${2} ppi = ${3}",
orderedBlock.Name,
orderedBlock.TotalQuantityOfShape().ToString(),
orderedBlock.Price.ToString(),
orderedBlock.Total().ToString()));

Console.WriteLine(string.Format("Red Color Surcharge {0} @ ${1} ppi = ${2}",
orderedBlock.NumberOfRedShape,
orderedBlock.AdditionalCharge,
(orderedBlock.NumberOfRedShape * orderedBlock.AdditionalCharge) ));

}

RedPaintSurcharge();
}

public void RedPaintSurcharge()
{
Console.WriteLine("Red Color Surcharge " + TotalAmountOfRedShapes() + " @ $" + base.OrderedBlocks[0].AdditionalCharge + " ppi = $" + TotalPriceRedPaintSurcharge());
Console.WriteLine(string.Format("\nRed Color Surcharge Total {0} ppi = ${1}",
TotalAmountOfRedShapes().ToString(),
TotalPriceRedPaintSurcharge().ToString() ));
}

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

public int TotalPriceRedPaintSurcharge()
{
return TotalAmountOfRedShapes() * base.OrderedBlocks[0].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();
}
public void OrderSquareDetails()
{
Console.WriteLine("\nSquares " + base.OrderedBlocks[0].TotalQuantityOfShape() + " @ $" + base.OrderedBlocks[0].Price + " ppi = $" + base.OrderedBlocks[0].Total());
}
public void OrderTriangleDetails()
{
Console.WriteLine("Triangles " + base.OrderedBlocks[1].TotalQuantityOfShape() + " @ $" + base.OrderedBlocks[1].Price + " ppi = $" + base.OrderedBlocks[1].Total());
}
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)
int redShapesTotal = 0;
foreach (var orderedBlock in OrderedBlocks)
{
row += AlignCentre(column, width) + "|";
redShapesTotal += orderedBlock.NumberOfRedShape;
}

Console.WriteLine(row);
return redShapesTotal;
}

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

if (string.IsNullOrEmpty(text))
int paintSurchargeTotal = 0;
foreach (var orderedBlock in OrderedBlocks)
{
return new string(' ', width);
}
else
{
return text.PadRight(width - (width - text.Length) / 2).PadLeft(width);
paintSurchargeTotal += (orderedBlock.NumberOfRedShape * orderedBlock.AdditionalCharge);
}
return paintSurchargeTotal;
}

}
}
51 changes: 49 additions & 2 deletions Order.Management/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,58 @@ abstract class Order
public int OrderNumber { get; set; }
public List<Shape> OrderedBlocks { get; set; }

public int ReportTableWidth { get; set; }

public abstract void GenerateReport();

public string ToString()
public void GenerateReportDetail(params string[] reportDetailColumns)
{
return "\nName: " + CustomerName + " Address: " + Address + " Due Date: " + DueDate + " Order #: " + OrderNumber;
PrintLine();
PrintRow(reportDetailColumns);
PrintLine();
foreach (var orderedblock in OrderedBlocks)
{
PrintRow(orderedblock.Name, orderedblock.NumberOfRedShape.ToString(), orderedblock.NumberOfBlueShape.ToString(), orderedblock.NumberOfYellowShape.ToString());
}
PrintLine();
}

public string ReportSummaryHeader()
{
return string.Format("\nName: {0} Address: {1} Due Date: {2} Order #: {3} ", CustomerName, Address, DueDate, OrderNumber);
}

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

public void PrintRow(params string[] columns)
{
int width = (ReportTableWidth - 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);
}
}

}
}
58 changes: 8 additions & 50 deletions Order.Management/PaintingReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,62 +6,20 @@ namespace Order.Management
{
class PaintingReport : Order
{
public int tableWidth = 73;
public PaintingReport(string customerName, string customerAddress, string dueDate, List<Shape> shapes)
{
base.CustomerName = customerName;
base.Address = customerAddress;
base.DueDate = dueDate;
base.OrderedBlocks = shapes;
CustomerName = customerName;
Address = customerAddress;
DueDate = dueDate;
OrderedBlocks = shapes;
ReportTableWidth = 73;
}

public override void GenerateReport()
{
Console.WriteLine("\nYour painting report has been generated: ");
Console.WriteLine(base.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);
}
Console.WriteLine(ReportSummaryHeader());
GenerateReportDetail(" ", " Red ", " Blue ", " Yellow ");
}
}
}
Loading