/// <summary> /// Displaying the page. /// </summary> public override void Display() { base.Display(); if (Data.Shapes == null || Data.Shapes.Count == 0) { Output.DisplayInfo("Collection is empty\n\nPress any key to navigate home"); Input.AnyKey(); Program.NavigateHome(); } var choiceMethod = Input.ReadEnum <SortShapesBy>("Choose the sort method"); switch (choiceMethod) { case SortShapesBy.Area: Data.Shapes = ShapeSorter.SortByAscending(Data.Shapes, choiceMethod).ToList(); break; case SortShapesBy.Perimeter: Data.Shapes = ShapeSorter.SortByAscending(Data.Shapes, choiceMethod).ToList(); break; default: throw new ArgumentOutOfRangeException(); } ShapePrinter.Print(Data.Shapes); Output.WriteLine("Press any key to navigate home"); Input.AnyKey(); Program.NavigateBack(); }
static void Main(string[] args) { var printer = new ShapePrinter(); var badRectangle = new Rectangle {Height = 10, Length = 20}; printer.PrintShapeArea(badRectangle); }
public void FailsToParseInvalidFile() { string currentDirectory = Directory.GetCurrentDirectory(); string path = Path.Combine(currentDirectory, "../../invalidShapeName.csv"); Console.Out.WriteLine("path: " + path); ShapePrinter printer = new ShapePrinter(filePath: path); }
public void CanFindFileThatExists() { string currentDirectory = Directory.GetCurrentDirectory(); string path = Path.Combine(currentDirectory, "../../empty.csv"); Console.Out.WriteLine("path: " + path); ShapePrinter printer = new ShapePrinter(filePath: path); }
static void Main(string[] args) { var badPrinter = new ShapePrinter(); var rectangle = new Rectangle { Height = 10, Length = 20 }; var circle = new Circle { Radius = 5 }; badPrinter.PrintShapeArea(rectangle); badPrinter.PrintShapeArea(circle); }
static void Main(string[] args) { List <Shape> shapes = new List <Shape>(); shapes.Add(new Circle(1)); shapes.Add(new Triangle(6, 5, 4)); shapes.Add(new RightAngledTriangle(3, 4)); shapes.Add(new Square(10)); foreach (Shape shape in shapes) { ShapePrinter.Print(shape); } }
static void Main(string[] args) { List <Shape> shapes = new List <Shape>(); shapes.Add(new Circle(1)); shapes.Add(new Triangle(6, 5, 4)); shapes.Add(new RightAngledTriangle(3, 4)); foreach (Shape shape in shapes) { ShapePrinter.Print(shape); } Console.WriteLine("Для завершения нажмите любую клавишу..."); Console.ReadKey(); }
/// <summary> /// Displays the page. /// </summary> public override void Display() { base.Display(); if (Data.Shapes == null || Data.Shapes.Count == 0) { Output.DisplayInfo("Collection is empty!"); } else { ShapePrinter.Print(Data.Shapes); } Output.WriteLine("Press any key to navigate home"); Input.AnyKey(); Program.NavigateBack(); }
static void Main(string[] args) { List <IPrintable> printables = new List <IPrintable>(); printables.Add(new Circle(1)); printables.Add(new Triangle(6, 5, 4)); printables.Add(new RightAngledTriangle(3, 4)); printables.Add(new Square(10)); foreach (var printable in printables) { ShapePrinter.Print(printable); } Console.WriteLine("Для завершения нажмите любую клавишу..."); Console.ReadKey(); }
/// <summary> /// Displays the page. /// </summary> public override void Display() { base.Display(); try { if (Data.Shapes == null || Data.Shapes.Count == 0) { Output.DisplayInfo("Collection is empty!"); } else { var choice = Input.ReadEnum <Quarter>("Enter the Quarter"); var collection = ShapeSorter .SortByDescending(_shapeFinder.Find(Data.Shapes, choice), SortShapesBy.Perimeter).ToList(); var path = Input.ReadString("Enter file path: "); _fileManager.Save(path, collection); ShapePrinter.Print(collection); } } catch (ArgumentException e) { Output.DisplayError(e.Message + e.ParamName); } catch (FileNotFoundException e) { Output.DisplayError(e.Message); } catch (IOException e) { Output.DisplayError(e.Message); } catch (Exception e) { Output.DisplayError(e.Message); } Output.DisplayInfo("Press any key to navigate home"); Input.AnyKey(); Program.NavigateBack(); }
public void CannotFindMissingFile() { ShapePrinter printer = new ShapePrinter(filePath: "notFound.txt"); }