diff --git a/.idea/.idea.Order.Management/.idea/.gitignore b/.idea/.idea.Order.Management/.idea/.gitignore new file mode 100644 index 0000000..57358f7 --- /dev/null +++ b/.idea/.idea.Order.Management/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/modules.xml +/projectSettingsUpdater.xml +/.idea.Order.Management.iml +/contentModel.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/.idea.Order.Management/.idea/.name b/.idea/.idea.Order.Management/.idea/.name new file mode 100644 index 0000000..e2dbe2f --- /dev/null +++ b/.idea/.idea.Order.Management/.idea/.name @@ -0,0 +1 @@ +Order.Management \ No newline at end of file diff --git a/.idea/.idea.Order.Management/.idea/encodings.xml b/.idea/.idea.Order.Management/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.Order.Management/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.Order.Management/.idea/indexLayout.xml b/.idea/.idea.Order.Management/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.Order.Management/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.Order.Management/.idea/vcs.xml b/.idea/.idea.Order.Management/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/.idea.Order.Management/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/.idea.OrderManagementPR/.idea/.gitignore b/.idea/.idea.OrderManagementPR/.idea/.gitignore new file mode 100644 index 0000000..62acf0e --- /dev/null +++ b/.idea/.idea.OrderManagementPR/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/projectSettingsUpdater.xml +/contentModel.xml +/.idea.OrderManagementPR.iml +/modules.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/.idea.OrderManagementPR/.idea/.name b/.idea/.idea.OrderManagementPR/.idea/.name new file mode 100644 index 0000000..7a125ff --- /dev/null +++ b/.idea/.idea.OrderManagementPR/.idea/.name @@ -0,0 +1 @@ +OrderManagementPR \ No newline at end of file diff --git a/.idea/.idea.OrderManagementPR/.idea/encodings.xml b/.idea/.idea.OrderManagementPR/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.OrderManagementPR/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/.idea.OrderManagementPR/.idea/indexLayout.xml b/.idea/.idea.OrderManagementPR/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/.idea/.idea.OrderManagementPR/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/.idea.OrderManagementPR/.idea/vcs.xml b/.idea/.idea.OrderManagementPR/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/.idea.OrderManagementPR/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Order.Management.PR/Circle.cs b/Order.Management.PR/Circle.cs new file mode 100644 index 0000000..9824ecc --- /dev/null +++ b/Order.Management.PR/Circle.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Order.Management +{ + class Circle : Shape + { + public int circlePrice = 3; + 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 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); + } + } +} diff --git a/Order.Management.PR/CuttingListReport.cs b/Order.Management.PR/CuttingListReport.cs new file mode 100644 index 0000000..125d45f --- /dev/null +++ b/Order.Management.PR/CuttingListReport.cs @@ -0,0 +1,68 @@ +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 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); + } + + 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); + } + } + + + } +} diff --git a/Order.Management.PR/InvoiceReport.cs b/Order.Management.PR/InvoiceReport.cs new file mode 100644 index 0000000..78443c3 --- /dev/null +++ b/Order.Management.PR/InvoiceReport.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Order.Management +{ + class InvoiceReport : Order + { + public int tableWidth = 73; + public InvoiceReport(string customerName, string customerAddress, string dueDate, List 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(); + } + + public void RedPaintSurcharge() + { + Console.WriteLine("Red Color Surcharge " + TotalAmountOfRedShapes() + " @ $" + base.OrderedBlocks[0].AdditionalCharge + " ppi = $" + TotalPriceRedPaintSurcharge()); + } + + 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) + { + 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); + } + } + } +} diff --git a/Order.Management.PR/Order.Management.csproj b/Order.Management.PR/Order.Management.csproj new file mode 100644 index 0000000..958d2f1 --- /dev/null +++ b/Order.Management.PR/Order.Management.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.0 + + + diff --git a/Order.Management.PR/Order.cs b/Order.Management.PR/Order.cs new file mode 100644 index 0000000..235c789 --- /dev/null +++ b/Order.Management.PR/Order.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Order.Management +{ + abstract class Order + { + public string CustomerName { get; set; } + public string Address { get; set; } + public string DueDate { get; set; } + public int OrderNumber { get; set; } + public List OrderedBlocks { get; set; } + + public abstract void GenerateReport(); + + public string ToString() + { + return "\nName: " + CustomerName + " Address: " + Address + " Due Date: " + DueDate + " Order #: " + OrderNumber; + } + } +} diff --git a/Order.Management.PR/PaintingReport.cs b/Order.Management.PR/PaintingReport.cs new file mode 100644 index 0000000..9b61c83 --- /dev/null +++ b/Order.Management.PR/PaintingReport.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Order.Management +{ + class PaintingReport : Order + { + public int tableWidth = 73; + public PaintingReport(string customerName, string customerAddress, string dueDate, List shapes) + { + base.CustomerName = customerName; + base.Address = customerAddress; + base.DueDate = dueDate; + base.OrderedBlocks = shapes; + } + 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); + } + } + } +} diff --git a/Order.Management.PR/Program.cs b/Order.Management.PR/Program.cs new file mode 100644 index 0000000..1422f85 --- /dev/null +++ b/Order.Management.PR/Program.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; + +namespace Order.Management +{ + class Program + { + // Main entry + static void Main(string[] args) + { + var (customerName, address, dueDate) = CustomerInfoInput(); + + var orderedShapes = CustomerOrderInput(); + + InvoiceReport(customerName, address, dueDate, orderedShapes); + + CuttingListReport(customerName, address, dueDate, orderedShapes); + + PaintingReport(customerName, address, dueDate, orderedShapes); + } + + // Order Circle Input + public static Circle OrderCirclesInput() + { + Console.Write("\nPlease input the number of Red Circle: "); + int redCircle = Convert.ToInt32(userInput()); + Console.Write("Please input the number of Blue Circle: "); + int blueCircle = Convert.ToInt32(userInput()); + Console.Write("Please input the number of Yellow Circle: "); + int yellowCircle = Convert.ToInt32(userInput()); + + Circle circle = new Circle(redCircle, blueCircle, yellowCircle); + return circle; + } + + // Order Squares Input + public static Square OrderSquaresInput() + { + Console.Write("\nPlease input the number of Red Squares: "); + int redSquare = Convert.ToInt32(userInput()); + Console.Write("Please input the number of Blue Squares: "); + int blueSquare = Convert.ToInt32(userInput()); + Console.Write("Please input the number of Yellow Squares: "); + int yellowSquare = Convert.ToInt32(userInput()); + + Square square = new Square(redSquare, blueSquare, yellowSquare); + return square; + } + + // Order Triangles Input + public static Triangle OrderTrianglesInput() + { + Console.Write("\nPlease input the number of Red Triangles: "); + int redTriangle = Convert.ToInt32(userInput()); + Console.Write("Please input the number of Blue Triangles: "); + int blueTriangle = Convert.ToInt32(userInput()); + Console.Write("Please input the number of Yellow Triangles: "); + int yellowTriangle = Convert.ToInt32(userInput()); + + Triangle triangle = new Triangle(redTriangle, blueTriangle, yellowTriangle); + return triangle; + } + + // User Console Input + public static string userInput() + { + string input = Console.ReadLine(); + while (string.IsNullOrEmpty(input)) + { + Console.WriteLine("please enter valid details"); + input = Console.ReadLine(); + + } + return input; + } + + // Generate Painting Report + private static void PaintingReport(string customerName, string address, string dueDate, List orderedShapes) + { + PaintingReport paintingReport = new PaintingReport(customerName, address, dueDate, orderedShapes); + paintingReport.GenerateReport(); + } + + // Generate Painting Report + private static void CuttingListReport(string customerName, string address, string dueDate, List orderedShapes) + { + CuttingListReport cuttingListReport = new CuttingListReport(customerName, address, dueDate, orderedShapes); + cuttingListReport.GenerateReport(); + } + + // Generate Invoice Report + private static void InvoiceReport(string customerName, string address, string dueDate, List orderedShapes) + { + InvoiceReport invoiceReport = new InvoiceReport(customerName, address, dueDate, orderedShapes); + invoiceReport.GenerateReport(); + } + + // Get customer Info + private static (string customerName, string address, string dueDate) CustomerInfoInput() + { + Console.Write("Please input your Name: "); + string customerName = userInput(); + Console.Write("Please input your Address: "); + string address = userInput(); + Console.Write("Please input your Due Date: "); + string dueDate = userInput(); + return (customerName, address, dueDate); + } + + // Get order input + private static List CustomerOrderInput() + { + Square square = OrderSquaresInput(); + Triangle triangle = OrderTrianglesInput(); + Circle circle = OrderCirclesInput(); + + var orderedShapes = new List(); + orderedShapes.Add(square); + orderedShapes.Add(triangle); + orderedShapes.Add(circle); + return orderedShapes; + } + } +} diff --git a/Order.Management.PR/Shape.cs b/Order.Management.PR/Shape.cs new file mode 100644 index 0000000..7f5c61c --- /dev/null +++ b/Order.Management.PR/Shape.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Order.Management +{ + abstract class Shape + { + public string Name { get; set; } + public int Price { get; set; } + public int AdditionalCharge { get; set; } + public int NumberOfRedShape { get; set; } + public int NumberOfBlueShape { get; set; } + public int NumberOfYellowShape { get; set; } + public int TotalQuantityOfShape() + { + return NumberOfRedShape + NumberOfBlueShape + NumberOfYellowShape; + } + + public int AdditionalChargeTotal() + { + return NumberOfRedShape * AdditionalCharge; + } + public abstract int Total(); + + } +} diff --git a/Order.Management.PR/Square.cs b/Order.Management.PR/Square.cs new file mode 100644 index 0000000..017601e --- /dev/null +++ b/Order.Management.PR/Square.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Order.Management +{ + class Square : Shape + { + + public int SquarePrice = 1; + + public Square(int numberOfRedSquares, int numberOfBlueSquares, int numberOfYellowSquares) + { + Name = "Square"; + base.Price = SquarePrice; + AdditionalCharge = 1; + base.NumberOfRedShape = numberOfRedSquares; + base.NumberOfBlueShape = numberOfBlueSquares; + base.NumberOfYellowShape = numberOfYellowSquares; + } + + public override int Total() + { + return RedSquaresTotal() + BlueSquaresTotal() + YellowSquaresTotal(); + } + + public int RedSquaresTotal() + { + return (base.NumberOfRedShape * Price); + } + public int BlueSquaresTotal() + { + return (base.NumberOfBlueShape * Price); + } + public int YellowSquaresTotal() + { + return (base.NumberOfYellowShape * Price); + } + } +} diff --git a/Order.Management.PR/Triangle.cs b/Order.Management.PR/Triangle.cs new file mode 100644 index 0000000..dbf48ff --- /dev/null +++ b/Order.Management.PR/Triangle.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Order.Management +{ + class Triangle : Shape + { + public int TrianglePrice = 2; + public Triangle(int numberOfRedTriangles, int numberOfBlueTriangles, int numberOfYellowTriangles) + { + Name = "Triangle"; + base.Price = TrianglePrice; + AdditionalCharge = 1; + base.NumberOfRedShape = numberOfRedTriangles; + base.NumberOfBlueShape = numberOfBlueTriangles; + base.NumberOfYellowShape = numberOfYellowTriangles; + } + + public override int Total() + { + return RedTrianglesTotal() + BlueTrianglesTotal() + YellowTrianglesTotal(); + } + + public int RedTrianglesTotal() + { + return (base.NumberOfRedShape * Price); + } + public int BlueTrianglesTotal() + { + return (base.NumberOfBlueShape * Price); + } + public int YellowTrianglesTotal() + { + return (base.NumberOfYellowShape * Price); + } + +} +} diff --git a/OrderManagementPR.sln b/OrderManagementPR.sln new file mode 100644 index 0000000..1e06e36 --- /dev/null +++ b/OrderManagementPR.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Order.Management", "Order.Management.PR\Order.Management.csproj", "{64FF93AB-0B53-4F63-B0F7-AC2218503640}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {64FF93AB-0B53-4F63-B0F7-AC2218503640}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {64FF93AB-0B53-4F63-B0F7-AC2218503640}.Debug|Any CPU.Build.0 = Debug|Any CPU + {64FF93AB-0B53-4F63-B0F7-AC2218503640}.Release|Any CPU.ActiveCfg = Release|Any CPU + {64FF93AB-0B53-4F63-B0F7-AC2218503640}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal