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
35 changes: 6 additions & 29 deletions Order.Management/Circle.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;

namespace Order.Management
{
class Circle : Shape
internal class Circle : Shape
{
public int circlePrice = 3;
public Circle(int red, int blue, int yellow)
private const int CirclePrice = 3;
public Circle(List<ShapeVariant> shapeVariants) : base(shapeVariants)
{
Name = "Circle";
base.Price = circlePrice;
AdditionalCharge = 1;
base.NumberOfRedShape = red;
base.NumberOfBlueShape = blue;
base.NumberOfYellowShape = yellow;
}
public override int Total()
{
return RedCirclesTotal() + BlueCirclesTotal() + YellowCirclesTotal();
}

public int RedCirclesTotal()
{
return (base.NumberOfRedShape * Price);
}
public int BlueCirclesTotal()
{
return (base.NumberOfBlueShape * Price);
}
public int YellowCirclesTotal()
{
return (base.NumberOfYellowShape * Price);
Price = CirclePrice;
}
}
}
}
24 changes: 24 additions & 0 deletions Order.Management/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Order.Management
{
internal static class Constants
{
public const int AdditionalCharge = 1;

public const int SmallTableWidth = 20;
public const int LargeTableWidth = 73;
}

public enum ShapeTypes
{
Square = 0,
Triangle = 1,
Circle = 2,
}

public enum ShapeColors
{
Red = 1,
Blue = 2,
Yellow = 3,
}
}
54 changes: 6 additions & 48 deletions Order.Management/CuttingListReport.cs
Original file line number Diff line number Diff line change
@@ -1,68 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;

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

public override void GenerateReport()
{
Console.WriteLine("\nYour cutting list has been generated: ");
Console.WriteLine(base.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();
}
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);
GenerateTable();
}

public string AlignCentre(string text, int width)
public void GenerateTable()
{
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);
}
ReportHelper.GenerateCuttingListReport(OrderedBlocks);
}


}
}
}
89 changes: 23 additions & 66 deletions Order.Management/InvoiceReport.cs
Original file line number Diff line number Diff line change
@@ -1,98 +1,55 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

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

public override void GenerateReport()
{
Console.WriteLine("\nYour invoice report has been generated: ");
Console.WriteLine(base.ToString());
GenerateTable();
OrderSquareDetails();
OrderTriangleDetails();
OrderCircleDetails();
RedPaintSurcharge();
}
Console.WriteLine();

public void RedPaintSurcharge()
{
Console.WriteLine("Red Color Surcharge " + TotalAmountOfRedShapes() + " @ $" + base.OrderedBlocks[0].AdditionalCharge + " ppi = $" + TotalPriceRedPaintSurcharge());
}
var shapeTypes = Enum.GetValues(typeof(ShapeTypes)).Cast<ShapeTypes>().ToList();
foreach (var shapeType in shapeTypes)
{
OrderTypeDetails(shapeType);
}

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

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()
public void VariantSurcharge()
{
Console.WriteLine("Triangles " + base.OrderedBlocks[1].TotalQuantityOfShape() + " @ $" + base.OrderedBlocks[1].Price + " ppi = $" + base.OrderedBlocks[1].Total());
Console.WriteLine("Shape Surcharge " + TotalQtyOfSurchargeShapes() + " @ $" + Constants.AdditionalCharge + " ppi = $" + TotalPriceSurcharge());
}
public void OrderCircleDetails()

public int TotalQtyOfSurchargeShapes()
{
Console.WriteLine("Circles " + base.OrderedBlocks[2].TotalQuantityOfShape() + " @ $" + base.OrderedBlocks[2].Price + " ppi = $" + base.OrderedBlocks[2].Total());
return base.OrderedBlocks.Sum(b => b.AdditionalChargeQty());
}
public void PrintLine()

public int TotalPriceSurcharge()
{
Console.WriteLine(new string('-', tableWidth));
return OrderedBlocks.Sum(b => b.AdditionalChargeTotal());
}

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

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

Console.WriteLine(row);
ReportHelper.GenerateReport(OrderedBlocks);
}

public string AlignCentre(string text, int width)
public void OrderTypeDetails(ShapeTypes shapeType)
{
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($"{shapeType.ToString()}s " + OrderedBlocks[(int)shapeType].TotalQuantityOfShape() + " @ $" + OrderedBlocks[(int)shapeType].Price + " ppi = $" + base.OrderedBlocks[(int)shapeType].Total());
}
}
}
}
26 changes: 14 additions & 12 deletions Order.Management/Order.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Order.Management
{
abstract class Order
internal class PaintingReport : 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 abstract void GenerateReport();
public PaintingReport(string customerName, string customerAddress, string dueDate, List<Shape> shapes)
: base(customerName, customerAddress, dueDate, shapes)
{
}
public override void GenerateReport()
{
Console.WriteLine("\nYour painting report has been generated: ");
Console.WriteLine(base.ToString());
GenerateTable();
}

public string ToString()
public void GenerateTable()
{
return "\nName: " + CustomerName + " Address: " + Address + " Due Date: " + DueDate + " Order #: " + OrderNumber;
ReportHelper.GenerateReport(OrderedBlocks);
}
}
}
}
Loading