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
117 changes: 117 additions & 0 deletions Order.Management/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Rules in this file were initially inferred by Visual Studio IntelliCode from the D:\source\Serko\OrderManagement\OrderManagement\Order.Management\ codebase based on best match to current usage at 11/02/2021
# You can modify the rules from these initially generated values to suit your own policies
# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
[*.cs]


#Core editorconfig formatting - indentation

#use soft tabs (spaces) for indentation
indent_style = space

#Formatting - indentation options
# Indentation and spacing
indent_size = 4
indent_style = space
tab_width = 4

# New line preferences
end_of_line = crlf
insert_final_newline = false


#indent switch case contents.
csharp_indent_case_contents = true
#indent switch labels
csharp_indent_switch_labels = true

#Formatting - new line options

#require members of object intializers to be on separate lines
csharp_new_line_before_members_in_object_initializers = true
#require braces to be on a new line for properties, accessors, methods, control_blocks, and types (also known as "Allman" style)
csharp_new_line_before_open_brace = properties, accessors, methods, control_blocks, types

#Formatting - organize using options

#sort System.* using directives alphabetically, and place them before other usings
dotnet_sort_system_directives_first = true

#Formatting - spacing options

#require a space before the colon for bases or interfaces in a type declaration
csharp_space_after_colon_in_inheritance_clause = true
#require a space after a keyword in a control flow statement such as a for loop
csharp_space_after_keywords_in_control_flow_statements = true
#require a space before the colon for bases or interfaces in a type declaration
csharp_space_before_colon_in_inheritance_clause = true
#remove space within empty argument list parentheses
csharp_space_between_method_call_empty_parameter_list_parentheses = false
#remove space between method call name and opening parenthesis
csharp_space_between_method_call_name_and_opening_parenthesis = false
#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call
csharp_space_between_method_call_parameter_list_parentheses = false
#remove space within empty parameter list parentheses for a method declaration
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list.
csharp_space_between_method_declaration_parameter_list_parentheses = false

#Formatting - wrapping options

#leave code block on single line
csharp_preserve_single_line_blocks = true

#Style - Code block preferences

#prefer curly braces even for one line of code
csharp_prefer_braces = true:suggestion

#Style - expression bodied member options

#prefer expression-bodied members for methods
csharp_style_expression_bodied_methods = true:suggestion
#prefer expression-bodied members for properties
csharp_style_expression_bodied_properties = true:suggestion

#Style - expression level options

#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_member_access = true:suggestion

#Style - Expression-level preferences

#prefer inferred tuple element names
dotnet_style_prefer_inferred_tuple_names = true:suggestion

#Style - implicit and explicit types

#prefer explicit type over var in all cases, unless overridden by another code style rule
csharp_style_var_elsewhere = false:suggestion
#prefer explicit type over var to declare variables with built-in system types such as int
csharp_style_var_for_built_in_types = false:suggestion
#prefer explicit type over var when the type is already mentioned on the right-hand side of a declaration
csharp_style_var_when_type_is_apparent = false:suggestion

#Style - language keyword and framework type options

#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion

#Style - modifier options

#prefer accessibility modifiers to be specified
dotnet_style_require_accessibility_modifiers = always:suggestion

#Style - Modifier preferences

#when this rule is set to a list of modifiers, prefer the specified ordering.
csharp_preferred_modifier_order = public,private,protected,static,override,abstract,virtual:suggestion

#Style - qualification options

#prefer fields not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_field = false:suggestion
#prefer methods not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_method = false:suggestion
#prefer properties not to be prefaced with this. or Me. in Visual Basic
dotnet_style_qualification_for_property = false:suggestion
39 changes: 14 additions & 25 deletions Order.Management/Circle.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Order.Management
namespace Order.Management
{
class Circle : Shape
{
public int circlePrice = 3;

public Circle(int red, int blue, int yellow)
{
Name = "Circle";
base.Price = circlePrice;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. call to "base" could be removed as this call is redundant, as constructor of derived class implicitly calls the constructor for the base class - please implement in subsequent cases.

Price = circlePrice;
AdditionalCharge = 1;
base.NumberOfRedShape = red;
base.NumberOfBlueShape = blue;
base.NumberOfYellowShape = yellow;
}
public override int Total()
{
return RedCirclesTotal() + BlueCirclesTotal() + YellowCirclesTotal();
NumberOfRedShape = red;
NumberOfBlueShape = blue;
NumberOfYellowShape = yellow;
}

public int RedCirclesTotal()
{
return (base.NumberOfRedShape * Price);
}
public int BlueCirclesTotal()
{
return (base.NumberOfBlueShape * Price);
}
public int YellowCirclesTotal()
{
return (base.NumberOfYellowShape * Price);
}
public override int Total => RedCirclesTotal+ BlueCirclesTotal+ YellowCirclesTotal;

public int RedCirclesTotal => (NumberOfRedShape * Price);

public int BlueCirclesTotal => (NumberOfBlueShape * Price);

public int YellowCirclesTotal => (NumberOfYellowShape * Price);

}
}
60 changes: 14 additions & 46 deletions Order.Management/CuttingListReport.cs
Original file line number Diff line number Diff line change
@@ -1,68 +1,36 @@
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<Shape> shapes)
public CuttingListReport(string customerName, string customerAddress, string dueDate, List<Shape> shapes) : base(customerName, customerAddress, dueDate, shapes)
{
base.CustomerName = customerName;
base.Address = customerAddress;
base.DueDate = dueDate;
base.OrderedBlocks = shapes;
tableWidth = 20;
OrderNumber += 1;
CustomerName = customerName;
Address = customerAddress;
DueDate = dueDate;
OrderedBlocks = shapes;
}

public override void GenerateReport()
{
Console.WriteLine("\nYour cutting list has been generated: ");
Console.WriteLine(base.ToString());
generateTable();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to exercise standard naming conventions using "PascalCase" for class/functions/method names and "camelCase" for instance variable, arrays, elements and parameter names. Please implement in subsequent cases

Console.WriteLine(ToString());
GenerateTable();
}
public void generateTable()

public override 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());
PrintRow("Square", OrderedBlocks[0].TotalQuantityOfShape.ToString());
PrintRow("Triangle", OrderedBlocks[1].TotalQuantityOfShape.ToString());
PrintRow("Circle", 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);
}
}


}
}
26 changes: 26 additions & 0 deletions Order.Management/IReport.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Order.Management
{
interface IReport
{
public void GenerateTable();
public void GenerateReport();

public void PrintLine()
{
}

public void PrintRow(params string[] columns)
{
}

public string AlignCentre(string text, int width)
{
return null;
}

}
}
97 changes: 21 additions & 76 deletions Order.Management/InvoiceReport.cs
Original file line number Diff line number Diff line change
@@ -1,98 +1,43 @@
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<Shape> shapes)
public InvoiceReport(string customerName, string customerAddress, string dueDate, List<Shape> orderedBlocks) : base (customerName, customerAddress, dueDate, orderedBlocks)
{
base.CustomerName = customerName;
base.Address = customerAddress;
base.DueDate = dueDate;
base.OrderedBlocks = shapes;
tableWidth = 73;
OrderNumber += 1;
CustomerName = customerName;
Address = customerAddress;
DueDate = dueDate;
OrderedBlocks = orderedBlocks;
}

public int TotalAmountOfRedShapes => OrderedBlocks[0].NumberOfRedShape + OrderedBlocks[1].NumberOfRedShape +
OrderedBlocks[2].NumberOfRedShape;

public int TotalPriceRedPaintSurcharge => TotalAmountOfRedShapes* OrderedBlocks[0].AdditionalCharge;

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

public void OrderSquareDetails() => Console.WriteLine("\nSquares " + OrderedBlocks[0].TotalQuantityOfShape + " @ $" + OrderedBlocks[0].Price + " ppi = $" + OrderedBlocks[0].Total);

public void OrderTriangleDetails() => Console.WriteLine("Triangles " + OrderedBlocks[1].TotalQuantityOfShape + " @ $" + OrderedBlocks[1].Price + " ppi = $" + OrderedBlocks[1].Total);

public void OrderCircleDetails() => Console.WriteLine("Circles " + OrderedBlocks[2].TotalQuantityOfShape + " @ $" + OrderedBlocks[2].Price + " ppi = $" + OrderedBlocks[2].Total);

public override void GenerateReport()
{
Console.WriteLine("\nYour invoice report has been generated: ");
Console.WriteLine(base.ToString());
Console.WriteLine(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 +
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as per comment regarding calls to "base"

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);
}
}
}
}
Loading