Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Order.Management/Circle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ namespace Order.Management
{
class Circle : Shape
{
public int circlePrice = 3;
private double circlePrice = 3;
public Circle(int red, int blue, int yellow)
{
Name = "Circle";
base.Price = circlePrice;
Price = circlePrice;
AdditionalCharge = 1;
base.NumberOfRedShape = red;
base.NumberOfBlueShape = blue;
base.NumberOfYellowShape = yellow;
NumberOfRedShape = red;
NumberOfBlueShape = blue;
NumberOfYellowShape = yellow;
}
public override int Total()
public override double Total()
{
return RedCirclesTotal() + BlueCirclesTotal() + YellowCirclesTotal();
}

public int RedCirclesTotal()
public double RedCirclesTotal()
{
return (base.NumberOfRedShape * Price);
return (NumberOfRedShape * Price);
}
public int BlueCirclesTotal()
public double BlueCirclesTotal()
{
return (base.NumberOfBlueShape * Price);
return (NumberOfBlueShape * Price);
}
public int YellowCirclesTotal()
public double YellowCirclesTotal()
{
return (base.NumberOfYellowShape * Price);
return (NumberOfYellowShape * Price);
}
}
}
30 changes: 14 additions & 16 deletions Order.Management/CuttingListReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,33 @@ namespace Order.Management
{
class CuttingListReport : Order
{
public int tableWidth = 20;
private int tableWidth = 20;
public CuttingListReport(string customerName, string customerAddress, string dueDate, List<Shape> shapes)
{
base.CustomerName = customerName;
base.Address = customerAddress;
base.DueDate = dueDate;
base.OrderedBlocks = shapes;
CustomerName = customerName;
Address = customerAddress;
DueDate = dueDate;
OrderedBlocks = shapes;
}

public override void GenerateReport()
{
Console.WriteLine("\nYour cutting list has been generated: ");
Console.WriteLine(base.ToString());
Console.WriteLine(ToString());
generateTable();
}
public void generateTable()
{
PrintLine();
PrintLine(new string('-', tableWidth));
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));
PrintLine(new string('-', tableWidth));
PrintRow("Square", OrderedBlocks[0].TotalQuantityOfShape().ToString());
PrintRow("Triangle", OrderedBlocks[1].TotalQuantityOfShape().ToString());
PrintRow("Circle", OrderedBlocks[2].TotalQuantityOfShape().ToString());
PrintLine(new string('-', tableWidth));
}
//Consider moving this to the base class


public void PrintRow(params string[] columns)
{
Expand Down
41 changes: 19 additions & 22 deletions Order.Management/InvoiceReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace Order.Management
{
class InvoiceReport : Order
{
public int tableWidth = 73;
private int tableWidth = 73;
public InvoiceReport(string customerName, string customerAddress, string dueDate, List<Shape> shapes)
{
base.CustomerName = customerName;
base.Address = customerAddress;
base.DueDate = dueDate;
base.OrderedBlocks = shapes;
CustomerName = customerName;
Address = customerAddress;
DueDate = dueDate;
OrderedBlocks = shapes;
}

public override void GenerateReport()
Expand All @@ -28,45 +28,42 @@ public override void GenerateReport()

public void RedPaintSurcharge()
{
Console.WriteLine("Red Color Surcharge " + TotalAmountOfRedShapes() + " @ $" + base.OrderedBlocks[0].AdditionalCharge + " ppi = $" + TotalPriceRedPaintSurcharge());
Console.WriteLine("Red Color Surcharge " + TotalAmountOfRedShapes() + " @ $" + OrderedBlocks[0].AdditionalCharge + " ppi = $" + TotalPriceRedPaintSurcharge());
}

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

public int TotalPriceRedPaintSurcharge()
{
return TotalAmountOfRedShapes() * base.OrderedBlocks[0].AdditionalCharge;
return TotalAmountOfRedShapes() * OrderedBlocks[0].AdditionalCharge;
}
public void GenerateTable()
{
PrintLine();
PrintLine(new string('-', tableWidth));
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();
PrintLine(new string('-', tableWidth));
PrintRow("Square", OrderedBlocks[0].NumberOfRedShape.ToString(), OrderedBlocks[0].NumberOfBlueShape.ToString(), OrderedBlocks[0].NumberOfYellowShape.ToString());
PrintRow("Triangle", OrderedBlocks[1].NumberOfRedShape.ToString(), OrderedBlocks[1].NumberOfBlueShape.ToString(), OrderedBlocks[1].NumberOfYellowShape.ToString());
PrintRow("Circle", OrderedBlocks[2].NumberOfRedShape.ToString(), OrderedBlocks[2].NumberOfBlueShape.ToString(), OrderedBlocks[2].NumberOfYellowShape.ToString());
PrintLine(new string('-', tableWidth));
}
public void OrderSquareDetails()
{
Console.WriteLine("\nSquares " + base.OrderedBlocks[0].TotalQuantityOfShape() + " @ $" + base.OrderedBlocks[0].Price + " ppi = $" + base.OrderedBlocks[0].Total());
Console.WriteLine("\nSquares " + OrderedBlocks[0].TotalQuantityOfShape() + " @ $" + OrderedBlocks[0].Price + " ppi = $" + OrderedBlocks[0].Total());
}
public void OrderTriangleDetails()
{
Console.WriteLine("Triangles " + base.OrderedBlocks[1].TotalQuantityOfShape() + " @ $" + base.OrderedBlocks[1].Price + " ppi = $" + base.OrderedBlocks[1].Total());
Console.WriteLine("Triangles " + OrderedBlocks[1].TotalQuantityOfShape() + " @ $" + OrderedBlocks[1].Price + " ppi = $" + 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));
Console.WriteLine("Circles " + OrderedBlocks[2].TotalQuantityOfShape() + " @ $" + OrderedBlocks[2].Price + " ppi = $" + OrderedBlocks[2].Total());
}
//Consider moving this to the base class

public void PrintRow(params string[] columns)
{
Expand Down
10 changes: 8 additions & 2 deletions Order.Management/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ abstract class Order
public List<Shape> OrderedBlocks { get; set; }

public abstract void GenerateReport();

public string ToString()

// Add override to eliminate warning
public override string ToString()
{
return "\nName: " + CustomerName + " Address: " + Address + " Due Date: " + DueDate + " Order #: " + OrderNumber;
}

public void PrintLine(string lineToPrint)
{
Console.WriteLine(lineToPrint);
}
}
}
26 changes: 11 additions & 15 deletions Order.Management/PaintingReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class PaintingReport : Order
public int tableWidth = 73;
public PaintingReport(string customerName, string customerAddress, string dueDate, List<Shape> shapes)
{
base.CustomerName = customerName;
base.Address = customerAddress;
base.DueDate = dueDate;
base.OrderedBlocks = shapes;
CustomerName = customerName;
Address = customerAddress;
DueDate = dueDate;
OrderedBlocks = shapes;
}
public override void GenerateReport()
{
Expand All @@ -23,19 +23,15 @@ public override void GenerateReport()

public void generateTable()
{
PrintLine();
PrintLine(new string('-', tableWidth));
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));
PrintLine(new string('-', tableWidth));
PrintRow("Square", OrderedBlocks[0].NumberOfRedShape.ToString(), OrderedBlocks[0].NumberOfBlueShape.ToString(), OrderedBlocks[0].NumberOfYellowShape.ToString());
PrintRow("Triangle", OrderedBlocks[1].NumberOfRedShape.ToString(), OrderedBlocks[1].NumberOfBlueShape.ToString(), OrderedBlocks[1].NumberOfYellowShape.ToString());
PrintRow("Circle", OrderedBlocks[2].NumberOfRedShape.ToString(), OrderedBlocks[2].NumberOfBlueShape.ToString(), OrderedBlocks[2].NumberOfYellowShape.ToString());
PrintLine(new string('-', tableWidth));
}
//Consider moving this to the base class

public void PrintRow(params string[] columns)
{
Expand Down
101 changes: 64 additions & 37 deletions Order.Management/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace Order.Management
{
Expand All @@ -22,12 +23,9 @@ static void Main(string[] args)
// 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());
int redCircle = ReadInt("\nPlease input the number of Red Circle: ");
int blueCircle = ReadInt("Please input the number of Blue Circle: ");
int yellowCircle = ReadInt("Please input the number of Yellow Circle: ");

Circle circle = new Circle(redCircle, blueCircle, yellowCircle);
return circle;
Expand All @@ -36,12 +34,9 @@ public static Circle OrderCirclesInput()
// 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());
int redSquare = ReadInt("\nPlease input the number of Red Squares: ");
int blueSquare = ReadInt("Please input the number of Blue Squares: ");
int yellowSquare = ReadInt("Please input the number of Yellow Squares: ");

Square square = new Square(redSquare, blueSquare, yellowSquare);
return square;
Expand All @@ -50,30 +45,14 @@ public static Square OrderSquaresInput()
// 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());
int redTriangle = ReadInt("\nPlease input the number of Red Triangles: ");
int blueTriangle = ReadInt("Please input the number of Blue Triangles: ");
int yellowTriangle = ReadInt("Please input the number of Yellow Triangles: ");

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<Shape> orderedShapes)
{
Expand All @@ -98,12 +77,9 @@ private static void InvoiceReport(string customerName, string address, string du
// 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();
string customerName = ReadName("Please input your Name: ");
string address = ReadAddress("Please input your Address: ");
string dueDate = ReadDate("Please input your Due Date: ").ToString();
return (customerName, address, dueDate);
}

Expand All @@ -120,5 +96,56 @@ private static List<Shape> CustomerOrderInput()
orderedShapes.Add(circle);
return orderedShapes;
}

// Create a funcion to read int only
private static int ReadInt(string prompt)
{
Console.Write(prompt);
string number = Console.ReadLine();
int value;
while(!Int32.TryParse(number, out value))
{
Console.Write("Not a valid number, try again: ");
number = Console.ReadLine();
}
return value;
}
// Create a function to read names only {first name + last name}
private static string ReadName(string prompt)
{
Console.Write(prompt);
string name = Console.ReadLine();
while (!Regex.IsMatch(name, @"^[A-Za-zÀ-ú]+ [A-Za-zÀ-ú]+$"))
{
Console.Write("Name must be 1-35 alfanum, try again: ");
name = Console.ReadLine();
}
return name;
}
// Create a fuction to read string only. This can be improved depending on the address format
public static string ReadAddress(string prompt)
{
Console.Write(prompt);
string input = Console.ReadLine();
while (string.IsNullOrEmpty(input))
{
Console.Write("Please enter a valid address: ");
input = Console.ReadLine();
}
return input;
}
// Create a function that returns a DateTime type only
private static DateTime ReadDate(string prompt)
{
Console.Write(prompt);
string date = Console.ReadLine();
DateTime value;
while (!DateTime.TryParse(date, out value))
{
Console.Write("Not a valid date, try again: ");
date = Console.ReadLine();
}
return value;
}
}
}
Loading