diff --git a/Order.Management.sln b/Order.Management.sln index 400236d..333e7ca 100644 --- a/Order.Management.sln +++ b/Order.Management.sln @@ -3,7 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.29519.87 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Order.Management", "Order.Management\Order.Management.csproj", "{1DAC7794-3F0E-4083-95A9-2E6FF9512C0C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Order.Management", "Order.Management\Order.Management.csproj", "{1DAC7794-3F0E-4083-95A9-2E6FF9512C0C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4B49C9C7-B797-4C36-B4F5-1EEA2554D763}" + ProjectSection(SolutionItems) = preProject + README.md = README.md + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Order.Management/CustomerInputHandler.cs b/Order.Management/CustomerInputHandler.cs new file mode 100644 index 0000000..59f8167 --- /dev/null +++ b/Order.Management/CustomerInputHandler.cs @@ -0,0 +1,105 @@ +using Order.Management.ToyBlocks; +using System; +using System.Collections.Generic; + +namespace Order.Management +{ + public class CustomerInputHandler + { + // Get customer Info + public (string customerName, string address, string dueDate) GetCustomerInfoInput() + { + string customerName = GetUserInputAsString("Please input your Name: "); + + string address = GetUserInputAsString("Please input your Address: "); + + // TODO: should probably be DateTime with valid user input for DateTime + string dueDate = GetUserInputAsString("Please input your Due Date: "); + + return (customerName, address, dueDate); + } + + public List GetCustomerOrderInput() + { + Square square = OrderSquaresInput(); + Triangle triangle = OrderTrianglesInput(); + Circle circle = OrderCirclesInput(); + + var orderedShapes = new List(); + orderedShapes.Add(square); + orderedShapes.Add(triangle); + orderedShapes.Add(circle); + + return orderedShapes; + } + + private static Circle OrderCirclesInput() + { + Console.WriteLine(); + int redCircle = GetUserInputAsInt("Please input the number of Red Circle: "); + int blueCircle = GetUserInputAsInt("Please input the number of Blue Circle: "); + int yellowCircle = GetUserInputAsInt("Please input the number of Yellow Circle: "); + + Circle circle = new Circle(redCircle, blueCircle, yellowCircle); + + return circle; + } + + private static Square OrderSquaresInput() + { + Console.WriteLine(); + int redSquare = GetUserInputAsInt("Please input the number of Red Squares: "); + int blueSquare = GetUserInputAsInt("Please input the number of Blue Squares: "); + int yellowSquare = GetUserInputAsInt("Please input the number of Yellow Squares: "); + + Square square = new Square(redSquare, blueSquare, yellowSquare); + return square; + } + + private static Triangle OrderTrianglesInput() + { + Console.WriteLine(); + int redTriangle = GetUserInputAsInt("Please input the number of Red Triangles: "); + int blueTriangle = GetUserInputAsInt("Please input the number of Blue Triangles: "); + int yellowTriangle = GetUserInputAsInt("Please input the number of Yellow Triangles: "); + + Triangle triangle = new Triangle(redTriangle, blueTriangle, yellowTriangle); + + return triangle; + } + + private static string GetUserInputAsString(string message) + { + if (string.IsNullOrWhiteSpace(message)) + { + throw new ArgumentNullException(nameof(message)); + } + + Console.Write(message); + + // Get user input + string input = Console.ReadLine().Trim(); + while (string.IsNullOrEmpty(input)) + { + Console.WriteLine("please enter valid details"); + Console.Write(message); + input = Console.ReadLine(); + } + + return input; + } + + private static int GetUserInputAsInt(string message) //TODO: example had ints being nullable from input + { + string input = GetUserInputAsString(message); + + while (!int.TryParse(input, out var _)) + { + Console.WriteLine("please enter valid details"); + input = GetUserInputAsString(message); + } + + return int.Parse(input); + } + } +} diff --git a/Order.Management/CuttingListReport.cs b/Order.Management/CuttingListReport.cs deleted file mode 100644 index 125d45f..0000000 --- a/Order.Management/CuttingListReport.cs +++ /dev/null @@ -1,68 +0,0 @@ -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/InvoiceReport.cs b/Order.Management/InvoiceReport.cs deleted file mode 100644 index 78443c3..0000000 --- a/Order.Management/InvoiceReport.cs +++ /dev/null @@ -1,98 +0,0 @@ -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/Order.cs b/Order.Management/Order.cs index 235c789..539dd0b 100644 --- a/Order.Management/Order.cs +++ b/Order.Management/Order.cs @@ -1,20 +1,17 @@ -using System; +using Order.Management.ToyBlocks; using System.Collections.Generic; -using System.Text; 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 string DueDate { get; set; } // TODO: should probably be DateTime public int OrderNumber { get; set; } - public List OrderedBlocks { get; set; } + public List OrderedBlocks { get; set; } = new List(); - public abstract void GenerateReport(); - - public string ToString() + public override string ToString() { return "\nName: " + CustomerName + " Address: " + Address + " Due Date: " + DueDate + " Order #: " + OrderNumber; } diff --git a/Order.Management/PaintingReport.cs b/Order.Management/PaintingReport.cs deleted file mode 100644 index 9b61c83..0000000 --- a/Order.Management/PaintingReport.cs +++ /dev/null @@ -1,67 +0,0 @@ -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/Program.cs b/Order.Management/Program.cs index 1422f85..3662ce6 100644 --- a/Order.Management/Program.cs +++ b/Order.Management/Program.cs @@ -1,124 +1,50 @@ -using System; -using System.Collections.Generic; +using Order.Management.Reports; namespace Order.Management { - class Program + public static class Program { // Main entry - static void Main(string[] args) + public static void Main(string[] args) { - var (customerName, address, dueDate) = CustomerInfoInput(); + var customerInput = new CustomerInputHandler(); + var (customerName, address, dueDate) = customerInput.GetCustomerInfoInput(); + var orderedShapes = customerInput.GetCustomerOrderInput(); - 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()); + var order = new Order + { + CustomerName = customerName, + Address = address, + DueDate = dueDate, + OrderedBlocks = orderedShapes + }; - Triangle triangle = new Triangle(redTriangle, blueTriangle, yellowTriangle); - return triangle; - } + InvoiceReport(order); - // User Console Input - public static string userInput() - { - string input = Console.ReadLine(); - while (string.IsNullOrEmpty(input)) - { - Console.WriteLine("please enter valid details"); - input = Console.ReadLine(); + CuttingListReport(order); - } - return input; + PaintingReport(order); } - // Generate Painting Report - private static void PaintingReport(string customerName, string address, string dueDate, List orderedShapes) + // Generate Painting Report + private static void PaintingReport(Order order) { - PaintingReport paintingReport = new PaintingReport(customerName, address, dueDate, orderedShapes); + PaintingReport paintingReport = new PaintingReport(order); paintingReport.GenerateReport(); } - // Generate Painting Report - private static void CuttingListReport(string customerName, string address, string dueDate, List orderedShapes) + // Generate Painting Report + private static void CuttingListReport(Order order) { - CuttingListReport cuttingListReport = new CuttingListReport(customerName, address, dueDate, orderedShapes); + CuttingListReport cuttingListReport = new CuttingListReport(order); cuttingListReport.GenerateReport(); } - // Generate Invoice Report - private static void InvoiceReport(string customerName, string address, string dueDate, List orderedShapes) + // Generate Invoice Report + private static void InvoiceReport(Order order) { - InvoiceReport invoiceReport = new InvoiceReport(customerName, address, dueDate, orderedShapes); + InvoiceReport invoiceReport = new InvoiceReport(order); 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/Reports/CuttingListReport.cs b/Order.Management/Reports/CuttingListReport.cs new file mode 100644 index 0000000..58b44fa --- /dev/null +++ b/Order.Management/Reports/CuttingListReport.cs @@ -0,0 +1,31 @@ +using System; + +namespace Order.Management.Reports +{ + public class CuttingListReport : Report + { + private const int TABLE_WIDTH = 20; + + public CuttingListReport(Order order) : base(order, TABLE_WIDTH) + { + } + + public override void GenerateReport() + { + Console.WriteLine("\nYour cutting list has been generated: "); + Console.WriteLine(Order.ToString()); + GenerateTable(); + } + + public void GenerateTable() + { + PrintLine(); + PrintRow(" ", " Qty "); + PrintLine(); + PrintRow("Square", Order.OrderedBlocks[0].TotalQuantityOfShape().ToString()); + PrintRow("Triangle", Order.OrderedBlocks[1].TotalQuantityOfShape().ToString()); + PrintRow("Circle", Order.OrderedBlocks[2].TotalQuantityOfShape().ToString()); + PrintLine(); + } + } +} diff --git a/Order.Management/Reports/InvoiceReport.cs b/Order.Management/Reports/InvoiceReport.cs new file mode 100644 index 0000000..66a1e51 --- /dev/null +++ b/Order.Management/Reports/InvoiceReport.cs @@ -0,0 +1,62 @@ +using System; + +namespace Order.Management.Reports +{ + public class InvoiceReport : Report + { + private const int TABLE_WIDTH = 73; + + public InvoiceReport(Order order) : base(order, TABLE_WIDTH) + { + } + + public override void GenerateReport() + { + Console.WriteLine("\nYour invoice report has been generated: "); + Console.WriteLine(Order.ToString()); + GenerateTable(); + OrderSquareDetails(); + OrderTriangleDetails(); + OrderCircleDetails(); + RedPaintSurcharge(); + } + + public void RedPaintSurcharge() + { + Console.WriteLine("Red Color Surcharge " + TotalAmountOfRedShapes() + " @ $" + Order.OrderedBlocks[0].AdditionalCharge + " ppi = $" + TotalPriceRedPaintSurcharge()); + } + + public int TotalAmountOfRedShapes() + { + return Order.OrderedBlocks[0].NumberOfRedShape + Order.OrderedBlocks[1].NumberOfRedShape + + Order.OrderedBlocks[2].NumberOfRedShape; + } + + public int TotalPriceRedPaintSurcharge() + { + return TotalAmountOfRedShapes() * Order.OrderedBlocks[0].AdditionalCharge; + } + public void GenerateTable() + { + PrintLine(); + PrintRow(" ", " Red ", " Blue ", " Yellow "); + PrintLine(); + PrintRow("Square", Order.OrderedBlocks[0].NumberOfRedShape.ToString(), Order.OrderedBlocks[0].NumberOfBlueShape.ToString(), Order.OrderedBlocks[0].NumberOfYellowShape.ToString()); + PrintRow("Triangle", Order.OrderedBlocks[1].NumberOfRedShape.ToString(), Order.OrderedBlocks[1].NumberOfBlueShape.ToString(), Order.OrderedBlocks[1].NumberOfYellowShape.ToString()); + PrintRow("Circle", Order.OrderedBlocks[2].NumberOfRedShape.ToString(), Order.OrderedBlocks[2].NumberOfBlueShape.ToString(), Order.OrderedBlocks[2].NumberOfYellowShape.ToString()); + PrintLine(); + } + public void OrderSquareDetails() + { + Console.WriteLine("\nSquares " + Order.OrderedBlocks[0].TotalQuantityOfShape() + " @ $" + Order.OrderedBlocks[0].Price + " ppi = $" + Order.OrderedBlocks[0].Total()); + } + public void OrderTriangleDetails() + { + Console.WriteLine("Triangles " + Order.OrderedBlocks[1].TotalQuantityOfShape() + " @ $" + Order.OrderedBlocks[1].Price + " ppi = $" + Order.OrderedBlocks[1].Total()); + } + public void OrderCircleDetails() + { + Console.WriteLine("Circles " + Order.OrderedBlocks[2].TotalQuantityOfShape() + " @ $" + Order.OrderedBlocks[2].Price + " ppi = $" + Order.OrderedBlocks[2].Total()); + } + } +} diff --git a/Order.Management/Reports/PaintingReport.cs b/Order.Management/Reports/PaintingReport.cs new file mode 100644 index 0000000..bd6d987 --- /dev/null +++ b/Order.Management/Reports/PaintingReport.cs @@ -0,0 +1,43 @@ +using System; + +namespace Order.Management.Reports +{ + public class PaintingReport : Report + { + private const int TABLE_WIDTH = 73; + + public PaintingReport(Order order) : base(order, TABLE_WIDTH) + { + } + + public override void GenerateReport() + { + Console.WriteLine("\nYour painting report has been generated: "); + Console.WriteLine(Order.ToString()); + GenerateTable(); + } + + public void GenerateTable() + { + PrintLine(); + PrintRow(" ", " Red ", " Blue ", " Yellow "); + PrintLine(); + PrintRow( + "Square", + Order.OrderedBlocks[0].NumberOfRedShape.ToString(), + Order.OrderedBlocks[0].NumberOfBlueShape.ToString(), + Order.OrderedBlocks[0].NumberOfYellowShape.ToString()); + PrintRow( + "Triangle", + Order.OrderedBlocks[1].NumberOfRedShape.ToString(), + Order.OrderedBlocks[1].NumberOfBlueShape.ToString(), + Order.OrderedBlocks[1].NumberOfYellowShape.ToString()); + PrintRow( + "Circle", + Order.OrderedBlocks[2].NumberOfRedShape.ToString(), + Order.OrderedBlocks[2].NumberOfBlueShape.ToString(), + Order.OrderedBlocks[2].NumberOfYellowShape.ToString()); + PrintLine(); + } + } +} diff --git a/Order.Management/Reports/Report.cs b/Order.Management/Reports/Report.cs new file mode 100644 index 0000000..6d054e4 --- /dev/null +++ b/Order.Management/Reports/Report.cs @@ -0,0 +1,51 @@ +using System; + +namespace Order.Management.Reports +{ + public abstract class Report + { + public int TableWidth { get; } + + public Order Order { get; } + + public Report(Order order, int tableWidth) + { + Order = order; + TableWidth = tableWidth; + } + + public abstract void GenerateReport(); + + 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/Circle.cs b/Order.Management/ToyBlocks/Circle.cs similarity index 87% rename from Order.Management/Circle.cs rename to Order.Management/ToyBlocks/Circle.cs index 9824ecc..b41eb2e 100644 --- a/Order.Management/Circle.cs +++ b/Order.Management/ToyBlocks/Circle.cs @@ -1,12 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Order.Management +namespace Order.Management.ToyBlocks { - class Circle : Shape + public class Circle : Shape { public int circlePrice = 3; + public Circle(int red, int blue, int yellow) { Name = "Circle"; @@ -16,6 +13,7 @@ public Circle(int red, int blue, int yellow) base.NumberOfBlueShape = blue; base.NumberOfYellowShape = yellow; } + public override int Total() { return RedCirclesTotal() + BlueCirclesTotal() + YellowCirclesTotal(); @@ -25,10 +23,12 @@ 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/Shape.cs b/Order.Management/ToyBlocks/Shape.cs similarity index 83% rename from Order.Management/Shape.cs rename to Order.Management/ToyBlocks/Shape.cs index 7f5c61c..55f4633 100644 --- a/Order.Management/Shape.cs +++ b/Order.Management/ToyBlocks/Shape.cs @@ -1,10 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Order.Management +namespace Order.Management.ToyBlocks { - abstract class Shape + // TODO: rename this to Block + public abstract class Shape { public string Name { get; set; } public int Price { get; set; } @@ -12,6 +9,7 @@ abstract class Shape public int NumberOfRedShape { get; set; } public int NumberOfBlueShape { get; set; } public int NumberOfYellowShape { get; set; } + public int TotalQuantityOfShape() { return NumberOfRedShape + NumberOfBlueShape + NumberOfYellowShape; @@ -21,7 +19,7 @@ public int AdditionalChargeTotal() { return NumberOfRedShape * AdditionalCharge; } - public abstract int Total(); + public abstract int Total(); } } diff --git a/Order.Management/Square.cs b/Order.Management/ToyBlocks/Square.cs similarity index 88% rename from Order.Management/Square.cs rename to Order.Management/ToyBlocks/Square.cs index 017601e..c38588c 100644 --- a/Order.Management/Square.cs +++ b/Order.Management/ToyBlocks/Square.cs @@ -1,12 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Order.Management +namespace Order.Management.ToyBlocks { - class Square : Shape + public class Square : Shape { - public int SquarePrice = 1; public Square(int numberOfRedSquares, int numberOfBlueSquares, int numberOfYellowSquares) @@ -28,10 +23,12 @@ 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/Triangle.cs b/Order.Management/ToyBlocks/Triangle.cs similarity index 87% rename from Order.Management/Triangle.cs rename to Order.Management/ToyBlocks/Triangle.cs index dbf48ff..5fc8813 100644 --- a/Order.Management/Triangle.cs +++ b/Order.Management/ToyBlocks/Triangle.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Order.Management +namespace Order.Management.ToyBlocks { - class Triangle : Shape + public class Triangle : Shape { public int TrianglePrice = 2; public Triangle(int numberOfRedTriangles, int numberOfBlueTriangles, int numberOfYellowTriangles) @@ -34,6 +30,5 @@ public int YellowTrianglesTotal() { return (base.NumberOfYellowShape * Price); } - -} + } }