From 82c262466f58fec65f2dcf59b62dc42b0375fe8d Mon Sep 17 00:00:00 2001 From: "Dan Zhao (CSI Interfusion Inc)" Date: Wed, 29 Jun 2022 22:08:02 +0800 Subject: [PATCH] Refactor Order Management --- Order.Management/Circle.cs | 37 ---- Order.Management/CommonConst.cs | 26 +++ Order.Management/CuttingListReport.cs | 68 -------- Order.Management/InvoiceReport.cs | 98 ----------- Order.Management/Order.cs | 22 --- Order.Management/Order/Order.cs | 49 ++++++ Order.Management/Order/ToyInfo.cs | 23 +++ Order.Management/PaintingReport.cs | 67 -------- Order.Management/Program.cs | 172 +++++++++++-------- Order.Management/Report/BaseReport.cs | 72 ++++++++ Order.Management/Report/CuttingListReport.cs | 41 +++++ Order.Management/Report/InvoiceReport.cs | 46 +++++ Order.Management/Report/PaintingReport.cs | 25 +++ Order.Management/Shape.cs | 27 --- Order.Management/Square.cs | 40 ----- Order.Management/Triangle.cs | 39 ----- 16 files changed, 379 insertions(+), 473 deletions(-) delete mode 100644 Order.Management/Circle.cs create mode 100644 Order.Management/CommonConst.cs delete mode 100644 Order.Management/CuttingListReport.cs delete mode 100644 Order.Management/InvoiceReport.cs delete mode 100644 Order.Management/Order.cs create mode 100644 Order.Management/Order/Order.cs create mode 100644 Order.Management/Order/ToyInfo.cs delete mode 100644 Order.Management/PaintingReport.cs create mode 100644 Order.Management/Report/BaseReport.cs create mode 100644 Order.Management/Report/CuttingListReport.cs create mode 100644 Order.Management/Report/InvoiceReport.cs create mode 100644 Order.Management/Report/PaintingReport.cs delete mode 100644 Order.Management/Shape.cs delete mode 100644 Order.Management/Square.cs delete mode 100644 Order.Management/Triangle.cs 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/CommonConst.cs b/Order.Management/CommonConst.cs new file mode 100644 index 0000000..5078984 --- /dev/null +++ b/Order.Management/CommonConst.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; + +namespace Order.Management +{ + class CommonConst + { + public const decimal SquarePrice = 1; + public const decimal TrianglePrice = 2; + public const decimal CirclePrice = 3; + public const decimal RedAdditionalCharge = 1; + + public static List ShapeList = new List() + { + Shape.Square, + Shape.Triangle, + Shape.Circle, + }; + + public static List ColorList = new List() + { + Color.Red, + Color.Blue, + Color.Yellow + }; + } +} 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 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/Order/Order.cs b/Order.Management/Order/Order.cs new file mode 100644 index 0000000..d3f8bf5 --- /dev/null +++ b/Order.Management/Order/Order.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Order.Management +{ + public class Order + { + public string CustomerName { get; set; } + public string Address { get; set; } + public DateTime DueDate { get; set; } + public int OrderNumber { 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 CommonConst.TrianglePrice; + case Shape.Circle: + return CommonConst.CirclePrice; + case Shape.Square: + default: + return CommonConst.SquarePrice; + } + } + + public override string ToString() + { + return $"\nName: {CustomerName} Address: {Address} Due Date: {DueDate.ToShortDateString()} Order #: {OrderNumber}"; + } + } +} diff --git a/Order.Management/Order/ToyInfo.cs b/Order.Management/Order/ToyInfo.cs new file mode 100644 index 0000000..c644d15 --- /dev/null +++ b/Order.Management/Order/ToyInfo.cs @@ -0,0 +1,23 @@ +namespace Order.Management +{ + public class ToyInfo + { + public Shape Shape { get; set; } + public Color Color { get; set; } + public int Quantity { get; set; } + } + + public enum Shape + { + Square, + Triangle, + Circle + } + + public enum Color + { + Red, + Blue, + Yellow + } +} 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..1b42ccc 100644 --- a/Order.Management/Program.cs +++ b/Order.Management/Program.cs @@ -10,59 +10,62 @@ static void Main(string[] args) { var (customerName, address, dueDate) = CustomerInfoInput(); - var orderedShapes = CustomerOrderInput(); + var orderedInfo = CustomerOrderInput(); - InvoiceReport(customerName, address, dueDate, orderedShapes); + var order = new Order() + { + Address = address, + CustomerName = customerName, + DueDate = dueDate, + OrderNumber = GenerateOrderNumber(), + ToyInfos = orderedInfo + }; - CuttingListReport(customerName, address, dueDate, orderedShapes); + InvoiceReport(order); - 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; + CuttingListReport(order); + + PaintingReport(order); } - - // Order Squares Input - public static Square OrderSquaresInput() + + #region Customer/Order Info input + + // Get customer Info + private static (string customerName, string address, DateTime dueDate) CustomerInfoInput() { - 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; + Console.Write("Please input your Name: "); + string customerName = UserStringInput(); + Console.Write("Please input your Address: "); + string address = UserStringInput(); + Console.Write("Please input your Due Date: "); + DateTime dueDate = UserDateInput(); + return (customerName, address, dueDate); } - // Order Triangles Input - public static Triangle OrderTrianglesInput() + // Get order input + private static List CustomerOrderInput() { - 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; + var orderBlocks = new List(); + foreach (var shape in CommonConst.ShapeList) + { + Console.Write($"\n"); + foreach (Color color in CommonConst.ColorList) + { + Console.Write($"Please input the number of {color} {shape}: "); + int quantity = UserNumberInput(); + orderBlocks.Add(new ToyInfo() + { + Shape = shape, + Color = color, + Quantity = quantity + }); + } + } + return orderBlocks; } - // User Console Input - public static string userInput() + // User Console String Input + private static string UserStringInput() { string input = Console.ReadLine(); while (string.IsNullOrEmpty(input)) @@ -74,51 +77,70 @@ public static string userInput() return input; } - // Generate Painting Report - private static void PaintingReport(string customerName, string address, string dueDate, List orderedShapes) + // User Console Date Input + private static DateTime UserDateInput() { - PaintingReport paintingReport = new PaintingReport(customerName, address, dueDate, orderedShapes); - paintingReport.GenerateReport(); + string input = Console.ReadLine(); + DateTime dueDate; + while (!DateTime.TryParse(input, out dueDate)) + { + Console.WriteLine("please enter a valid Date"); + input = Console.ReadLine(); + } + return dueDate; } - // Generate Painting Report - private static void CuttingListReport(string customerName, string address, string dueDate, List orderedShapes) + // User Console Number Input + private static int UserNumberInput() { - CuttingListReport cuttingListReport = new CuttingListReport(customerName, address, dueDate, orderedShapes); - cuttingListReport.GenerateReport(); + 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(); + + } + return inputNumber; } - // Generate Invoice Report - private static void InvoiceReport(string customerName, string address, string dueDate, List orderedShapes) + //Generate a Random Order Number + private static int GenerateOrderNumber() { - InvoiceReport invoiceReport = new InvoiceReport(customerName, address, dueDate, orderedShapes); - invoiceReport.GenerateReport(); + return new Random().Next(); } - // Get customer Info - private static (string customerName, string address, string dueDate) CustomerInfoInput() + #endregion + + #region Generate Report + + // Generate Painting Report + private static void PaintingReport(Order order) { - 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); + PaintingReport paintingReport = new PaintingReport(order); + paintingReport.GenerateReport(); } - // Get order input - private static List CustomerOrderInput() + // Generate Cutting List Report + private static void CuttingListReport(Order order) + { + CuttingListReport cuttingListReport = new CuttingListReport(order); + cuttingListReport.GenerateReport(); + } + + // Generate Invoice Report + private static void InvoiceReport(Order order) { - Square square = OrderSquaresInput(); - Triangle triangle = OrderTrianglesInput(); - Circle circle = OrderCirclesInput(); - - var orderedShapes = new List(); - orderedShapes.Add(square); - orderedShapes.Add(triangle); - orderedShapes.Add(circle); - return orderedShapes; + InvoiceReport invoiceReport = new InvoiceReport(order); + invoiceReport.GenerateReport(); } + + #endregion } } diff --git a/Order.Management/Report/BaseReport.cs b/Order.Management/Report/BaseReport.cs new file mode 100644 index 0000000..86f1b53 --- /dev/null +++ b/Order.Management/Report/BaseReport.cs @@ -0,0 +1,72 @@ +using System; + +namespace Order.Management +{ + public abstract class BaseReport + { + private int _tableWidth = 73; + + protected readonly Order order; + protected BaseReport(Order order) + { + this.order = order; + } + + public abstract void GenerateReport(); + + protected void SetTableWidth(int width) + { + _tableWidth = width; + } + + protected void GenerateTable() + { + PrintLine(); + PrintRow(" ", " Red ", " Blue ", " Yellow "); + PrintLine(); + + foreach (Enum shape in CommonConst.ShapeList) + { + PrintRow( + shape, + order.GetCountByShapeAndColor(shape, Color.Red), + order.GetCountByShapeAndColor(shape, Color.Blue), + order.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 += AlignCentre(column.ToString(), width) + "|"; + } + + Console.WriteLine(row); + } + + private 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); + } + } + } +} \ No newline at end of file diff --git a/Order.Management/Report/CuttingListReport.cs b/Order.Management/Report/CuttingListReport.cs new file mode 100644 index 0000000..6ca1fa0 --- /dev/null +++ b/Order.Management/Report/CuttingListReport.cs @@ -0,0 +1,41 @@ +using System; + +namespace Order.Management +{ + class CuttingListReport : BaseReport + { + private int _tableWidth = 20; + + public CuttingListReport(Order order) : base(order) + { + } + + public override void GenerateReport() + { + try + { + SetTableWidth(_tableWidth); + Console.WriteLine("\nYour cutting list has been generated: "); + Console.WriteLine(order.ToString()); + GenerateCuttingListTable(); + } + catch(Exception ex) + { + Console.WriteLine("\nPrint cutting list report exception: " + ex.Message.ToString()); + } + } + + private void GenerateCuttingListTable() + { + PrintLine(); + PrintRow(" ", " Qty "); + PrintLine(); + + foreach (Enum shape in CommonConst.ShapeList) + { + PrintRow(shape, order.GetCountByShape(shape)); + } + PrintLine(); + } + } +} diff --git a/Order.Management/Report/InvoiceReport.cs b/Order.Management/Report/InvoiceReport.cs new file mode 100644 index 0000000..7e99c8e --- /dev/null +++ b/Order.Management/Report/InvoiceReport.cs @@ -0,0 +1,46 @@ +using System; + +namespace Order.Management +{ + class InvoiceReport : BaseReport + { + public InvoiceReport(Order order) : base(order) + { + } + + public override void GenerateReport() + { + try + { + Console.WriteLine("\nYour invoice report has been generated: "); + Console.WriteLine(order.ToString()); + GenerateTable(); + Console.WriteLine(); + ShowOrderDetailsByShape(); + ShowRedColorSurcharge(); + } + catch (Exception ex) + { + Console.WriteLine("\nPrint invoice report exception: " + ex.Message.ToString()); + } + } + + private void ShowOrderDetailsByShape() + { + foreach (var shape in CommonConst.ShapeList) + { + int shapeNumber = order.GetCountByShape(shape); + decimal unitPrice = order.GetShapePrice(shape); + Console.WriteLine( + $"{shape}s {shapeNumber} @ ${unitPrice} ppi = ${shapeNumber * unitPrice}"); + } + } + + private void ShowRedColorSurcharge() + { + int RedColorNumber = order.GetCountByColor(Color.Red); + Console.WriteLine( + $"Red Color Surcharge {order.GetCountByColor(Color.Red)} @ ${CommonConst.RedAdditionalCharge} ppi = ${RedColorNumber * CommonConst.RedAdditionalCharge}"); + } + } +} diff --git a/Order.Management/Report/PaintingReport.cs b/Order.Management/Report/PaintingReport.cs new file mode 100644 index 0000000..5eca5de --- /dev/null +++ b/Order.Management/Report/PaintingReport.cs @@ -0,0 +1,25 @@ +using System; + +namespace Order.Management +{ + class PaintingReport : BaseReport + { + public PaintingReport(Order order) : base(order) + { + } + + public override void GenerateReport() + { + try + { + Console.WriteLine("\nYour painting report has been generated: "); + Console.WriteLine(order.ToString()); + GenerateTable(); + } + catch (Exception ex) + { + Console.WriteLine("\nPrint painting report exception: " + ex.Message.ToString()); + } + } + } +} 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); - } - -} -}