diff --git a/Order.Management/Circle.cs b/Order.Management/Circle.cs deleted file mode 100644 index 9824ecc..0000000 --- a/Order.Management/Circle.cs +++ /dev/null @@ -1,37 +0,0 @@ -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/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/Domain/CustomerInfo.cs b/Order.Management/Domain/CustomerInfo.cs new file mode 100644 index 0000000..a6e3588 --- /dev/null +++ b/Order.Management/Domain/CustomerInfo.cs @@ -0,0 +1,12 @@ +using System; + +namespace Order.Management.Domain +{ + public class CustomerInfo + { + public string CustomerName { get; set; } + public string Address { get; set; } + public DateTime DueDate { get; set; } + + } +} diff --git a/Order.Management/Domain/OrderInfo.cs b/Order.Management/Domain/OrderInfo.cs new file mode 100644 index 0000000..8dc4c8b --- /dev/null +++ b/Order.Management/Domain/OrderInfo.cs @@ -0,0 +1,47 @@ +using Order.Management.Enums; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Order.Management.Domain +{ + public class OrderInfo + { + public int OrderNumber { get; set; } + public CustomerInfo CustomerInfo { get; set; } + public List ToyInfos { get; set; } + + public int GetCountByColor(Color color) + { + return ToyInfos.Where(item => item.Color.Equals(color)).ToList().Sum(item => item.Quantity); + } + + public int GetCountByShape(Enum shape) + { + return ToyInfos.Where(item => item.Shape.Equals(shape)).ToList().Sum(item => item.Quantity); + } + public int GetCountByShapeAndColor(Enum shape, Color color) + { + return ToyInfos.Where(item => item.Shape.Equals(shape) && item.Color.Equals(color)).ToList().Sum(item => item.Quantity); + } + + public decimal GetShapePrice(Enum shape) + { + switch (shape) + { + case Shape.Triangle: + return ToyPrice.TrianglePrice; + case Shape.Circle: + return ToyPrice.CirclePrice; + case Shape.Square: + default: + return ToyPrice.SquarePrice; + } + } + + public string ToMessage() + { + return $"\nName: {CustomerInfo.CustomerName} Address: {CustomerInfo.Address} Due Date: {CustomerInfo.DueDate.ToShortDateString()} Order #: {OrderNumber}"; + } + } +} diff --git a/Order.Management/Domain/ToyInfo.cs b/Order.Management/Domain/ToyInfo.cs new file mode 100644 index 0000000..b7a03bf --- /dev/null +++ b/Order.Management/Domain/ToyInfo.cs @@ -0,0 +1,11 @@ +using Order.Management.Enums; + +namespace Order.Management.Domain +{ + public class ToyInfo + { + public Shape Shape { get; set; } + public Color Color { get; set; } + public int Quantity { get; set; } + } +} diff --git a/Order.Management/Domain/ToyPrice.cs b/Order.Management/Domain/ToyPrice.cs new file mode 100644 index 0000000..aa6753f --- /dev/null +++ b/Order.Management/Domain/ToyPrice.cs @@ -0,0 +1,11 @@ + +namespace Order.Management.Domain +{ + public class ToyPrice + { + public const decimal SquarePrice = 1; + public const decimal TrianglePrice = 2; + public const decimal CirclePrice = 3; + public const decimal ExtraChargesWithRed = 1; + } +} diff --git a/Order.Management/Enums/Color.cs b/Order.Management/Enums/Color.cs new file mode 100644 index 0000000..8180d2f --- /dev/null +++ b/Order.Management/Enums/Color.cs @@ -0,0 +1,9 @@ +namespace Order.Management.Enums +{ + public enum Color + { + Red, + Blue, + Yellow + } +} diff --git a/Order.Management/Enums/ReportType.cs b/Order.Management/Enums/ReportType.cs new file mode 100644 index 0000000..657d013 --- /dev/null +++ b/Order.Management/Enums/ReportType.cs @@ -0,0 +1,10 @@ +using System; +namespace Order.Management.Enums +{ + public enum ReportType + { + CuttingList, + Invoice, + Painting + } +} diff --git a/Order.Management/Enums/Shape.cs b/Order.Management/Enums/Shape.cs new file mode 100644 index 0000000..97b0f72 --- /dev/null +++ b/Order.Management/Enums/Shape.cs @@ -0,0 +1,9 @@ +namespace Order.Management.Enums +{ + public enum Shape + { + Square, + Triangle, + Circle + } +} 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 deleted file mode 100644 index 235c789..0000000 --- a/Order.Management/Order.cs +++ /dev/null @@ -1,22 +0,0 @@ -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/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..3ca09ae 100644 --- a/Order.Management/Program.cs +++ b/Order.Management/Program.cs @@ -1,124 +1,21 @@ -using System; -using System.Collections.Generic; +using Order.Management.Services; +using Order.Management.Enums; namespace Order.Management { - class Program + public class Program { // Main entry static void Main(string[] args) { - var (customerName, address, dueDate) = CustomerInfoInput(); + var orderService = new OrderService(); + var orderInfo = orderService.GetCustomerInput(); + var reportService = new ReportService(orderInfo); - var orderedShapes = CustomerOrderInput(); + reportService.GenerateReport(ReportType.Invoice); + reportService.GenerateReport(ReportType.CuttingList); + reportService.GenerateReport(ReportType.Painting); - 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/Services/BaseReport.cs b/Order.Management/Services/BaseReport.cs new file mode 100644 index 0000000..0c6c152 --- /dev/null +++ b/Order.Management/Services/BaseReport.cs @@ -0,0 +1,73 @@ +using System; +using Order.Management.Domain; +using Order.Management.Enums; + +namespace Order.Management.Services +{ + public abstract class BaseReport + { + private int _tableWidth = 73; + protected readonly OrderInfo orderInfo; + protected BaseReport(OrderInfo orderInfo) + { + this.orderInfo = orderInfo; + } + + public abstract void GenerateReport(Enum reportType); + + protected void SetTableWidth(int width) + { + _tableWidth = width; + } + + protected void GenerateTable() + { + PrintLine(); + PrintRow(" ", " Red ", " Blue ", " Yellow "); + PrintLine(); + + foreach (Enum shape in Util.Util.ShapeList) + { + PrintRow( + shape, + orderInfo.GetCountByShapeAndColor(shape, Color.Red), + orderInfo.GetCountByShapeAndColor(shape, Color.Blue), + orderInfo.GetCountByShapeAndColor(shape, Color.Yellow) + ); + } + PrintLine(); + } + + protected void PrintLine() + { + Console.WriteLine(new string('-', _tableWidth)); + } + + protected void PrintRow(params object[] columns) + { + int width = (_tableWidth - columns.Length) / columns.Length; + string row = "|"; + + foreach (object column in columns) + { + row += AlignCneter(column.ToString(), width) + "|"; + } + + Console.WriteLine(row); + } + + private string AlignCneter(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/Services/OrderService.cs b/Order.Management/Services/OrderService.cs new file mode 100644 index 0000000..384a0a2 --- /dev/null +++ b/Order.Management/Services/OrderService.cs @@ -0,0 +1,130 @@ +using System; +using Order.Management.Domain; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace Order.Management.Services +{ + public class OrderService + { + public OrderInfo GetCustomerInput() + { + var customerInfoInput = CustomerInfoInput(); + + var toyInfoInput = ToyInfoInput(); + + return new OrderInfo() + { + OrderNumber = new Random().Next(), + CustomerInfo = customerInfoInput, + ToyInfos = toyInfoInput + }; + } + + // Get customer Info + private static CustomerInfo CustomerInfoInput() + { + var customerInfo = new CustomerInfo(); + Console.Write("Please input your Name: "); + customerInfo.CustomerName = UserNameStringInput(); + Console.Write("Please input your Address: "); + customerInfo.Address = UserStringInput(); + Console.Write("Please input your Due Date: "); + customerInfo.DueDate = UserDateInput(); + return customerInfo; + } + + // User Name String Input + private static string UserNameStringInput() + { + string input = Console.ReadLine(); + while (string.IsNullOrEmpty(input) && input.Length > 50) + { + Console.WriteLine("please enter valid details"); + input = Console.ReadLine(); + } + return input; + } + + // User Console String Input + private static string UserStringInput() + { + string input = Console.ReadLine(); + while (string.IsNullOrEmpty(input)) + { + Console.WriteLine("please enter valid details"); + input = Console.ReadLine(); + } + return input; + } + + // User Console Date Input + private static DateTime UserDateInput() + { + string input = Console.ReadLine(); + DateTime dueDate; + while (!DateTime.TryParse(input, out dueDate) && dueDate < DateTime.Now) + { + Console.WriteLine("please enter a valid Date"); + input = Console.ReadLine(); + } + + while (Convert.ToDateTime(input) < DateTime.Now) + { + Console.WriteLine("please enter a valid no less than date time now"); + input = Console.ReadLine(); + } + return dueDate; + } + + // Get order input + private static List ToyInfoInput() + { + var toylist = new List(); + foreach (var shape in Util.Util.ShapeList) + { + Console.Write($"\n"); + foreach (var color in Util.Util.ColorList) + { + Console.Write($"Please input the number of {color} {shape}: "); + int quantity = ToyCountInput(); + toylist.Add(new ToyInfo() + { + Shape = shape, + Color = color, + Quantity = quantity + }); + } + } + return toylist; + } + + // User Console Number Input + private static int ToyCountInput() + { + + Regex reg = new Regex(@"^\d+$"); + string input = Console.ReadLine(); + int inputNumber; + + if (string.IsNullOrWhiteSpace(input)) + { + input = "0"; + } + + while (!Int32.TryParse(input, out inputNumber)) + { + Console.WriteLine("please enter a valid number"); + input = Console.ReadLine(); + + } + + while (!reg.IsMatch(input) || Convert.ToInt32(input) < 0) + { + Console.WriteLine("please enter a valid number"); + input = Console.ReadLine(); + } + return Convert.ToInt32(input); + } + } +} diff --git a/Order.Management/Services/ReportService.cs b/Order.Management/Services/ReportService.cs new file mode 100644 index 0000000..a5b6ec2 --- /dev/null +++ b/Order.Management/Services/ReportService.cs @@ -0,0 +1,93 @@ +using System; +using Order.Management.Domain; +using Order.Management.Enums; + +namespace Order.Management.Services +{ + public class ReportService : BaseReport + { + public ReportService(OrderInfo orderInfo) : base(orderInfo) + { + } + public override void GenerateReport(Enum reportType) + { + try + { + switch (reportType) { + case ReportType.Invoice: + Console.WriteLine("\nYour invoice report has been generated: "); + Console.WriteLine(orderInfo.ToMessage()); + GenerateTable(); + Console.WriteLine(); + ShowOrderDetailsByShape(); + ShowRedColorSurcharge(); + ShowTotalCharge(); + break; + case ReportType.CuttingList: + SetTableWidth(20); + Console.WriteLine("\nYour cutting list has been generated: "); + Console.WriteLine(orderInfo.ToMessage()); + GenerateCuttingListTable(); + break; + case ReportType.Painting: + SetTableWidth(73); + Console.WriteLine("\nYour painting report has been generated: "); + Console.WriteLine(orderInfo.ToMessage()); + GenerateTable(); + break; + } + } + catch (Exception ex) + { + Console.WriteLine("\nPrint report exception: " + ex.Message.ToString()); + } + } + + private void ShowOrderDetailsByShape() + { + + foreach (var shape in Util.Util.ShapeList) + { + int shapeNumber = orderInfo.GetCountByShape(shape); + decimal unitPrice = orderInfo.GetShapePrice(shape); + Console.WriteLine( + $"{shape}s {shapeNumber} @ ${unitPrice} ppi = ${shapeNumber * unitPrice}"); + } + } + + private void ShowRedColorSurcharge() + { + int RedColorNumber = orderInfo.GetCountByColor(Color.Red); + Console.WriteLine( + $"Red Color Surcharge {orderInfo.GetCountByColor(Color.Red)} @ ${ToyPrice.ExtraChargesWithRed} ppi = ${RedColorNumber * ToyPrice.ExtraChargesWithRed}"); + } + + private void ShowTotalCharge() + { + int RedColorNumber = orderInfo.GetCountByColor(Color.Red); + decimal totalPrice = 0; + foreach (var shape in Util.Util.ShapeList) + { + int shapeNumber = orderInfo.GetCountByShape(shape); + decimal unitPrice = orderInfo.GetShapePrice(shape); + totalPrice += unitPrice * shapeNumber; + } + PrintLine(); + Console.WriteLine( + $"Total ${totalPrice + RedColorNumber * ToyPrice.ExtraChargesWithRed}"); + } + + private void GenerateCuttingListTable() + { + PrintLine(); + PrintRow(" ", " Qty "); + PrintLine(); + + foreach (Enum shape in Util.Util.ShapeList) + { + PrintRow(shape, orderInfo.GetCountByShape(shape)); + } + PrintLine(); + } + } +} diff --git a/Order.Management/Shape.cs b/Order.Management/Shape.cs deleted file mode 100644 index 7f5c61c..0000000 --- a/Order.Management/Shape.cs +++ /dev/null @@ -1,27 +0,0 @@ -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/Square.cs b/Order.Management/Square.cs deleted file mode 100644 index 017601e..0000000 --- a/Order.Management/Square.cs +++ /dev/null @@ -1,40 +0,0 @@ -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/Triangle.cs b/Order.Management/Triangle.cs deleted file mode 100644 index dbf48ff..0000000 --- a/Order.Management/Triangle.cs +++ /dev/null @@ -1,39 +0,0 @@ -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/Order.Management/Util/Util.cs b/Order.Management/Util/Util.cs new file mode 100644 index 0000000..25bf232 --- /dev/null +++ b/Order.Management/Util/Util.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using Order.Management.Enums; + +namespace Order.Management.Util +{ + public static class Util + { + public static List ShapeList = new List() + { + Shape.Square, + Shape.Triangle, + Shape.Circle, + }; + + public static List ColorList = new List() + { + Color.Red, + Color.Blue, + Color.Yellow + }; + + } +}