-
Notifications
You must be signed in to change notification settings - Fork 38
Gerardo Sullivan Code Review #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
8efbcd0
4ef85db
fb5087a
15461a7
6a9804f
e074d78
3aa2932
6e771ad
4c77acb
5682c54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| using Order.Management.ToyBlocks; | ||
| using System; | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace Order.Management | ||
| { | ||
| public class CustomerInputHandler | ||
| { | ||
| // Get customer Info | ||
| public (string customerName, string address, string dueDate) GetCustomerInfoInput() | ||
| { | ||
| string customerName = GetUserInputAsString("Please input your Name: "); | ||
|
|
||
| string address = GetUserInputAsString("Please input your Address: "); | ||
|
|
||
| // TODO: should probably be DateTime with valid user input for DateTime | ||
| string dueDate = GetUserInputAsString("Please input your Due Date: "); | ||
|
|
||
| return (customerName, address, dueDate); | ||
| } | ||
|
|
||
| public List<Shape> GetCustomerOrderInput() | ||
| { | ||
| Square square = OrderSquaresInput(); | ||
| Triangle triangle = OrderTrianglesInput(); | ||
| Circle circle = OrderCirclesInput(); | ||
|
|
||
| var orderedShapes = new List<Shape>(); | ||
| orderedShapes.Add(square); | ||
| orderedShapes.Add(triangle); | ||
| orderedShapes.Add(circle); | ||
|
|
||
| return orderedShapes; | ||
| } | ||
|
|
||
| private static Circle OrderCirclesInput() | ||
| { | ||
| Console.WriteLine(); | ||
| int redCircle = GetUserInputAsInt("Please input the number of Red Circle: "); | ||
| int blueCircle = GetUserInputAsInt("Please input the number of Blue Circle: "); | ||
| int yellowCircle = GetUserInputAsInt("Please input the number of Yellow Circle: "); | ||
|
|
||
| Circle circle = new Circle(redCircle, blueCircle, yellowCircle); | ||
|
|
||
| return circle; | ||
| } | ||
|
|
||
| private static Square OrderSquaresInput() | ||
| { | ||
| Console.WriteLine(); | ||
| int redSquare = GetUserInputAsInt("Please input the number of Red Squares: "); | ||
| int blueSquare = GetUserInputAsInt("Please input the number of Blue Squares: "); | ||
| int yellowSquare = GetUserInputAsInt("Please input the number of Yellow Squares: "); | ||
|
|
||
| Square square = new Square(redSquare, blueSquare, yellowSquare); | ||
| return square; | ||
| } | ||
|
|
||
| private static Triangle OrderTrianglesInput() | ||
| { | ||
| Console.WriteLine(); | ||
| int redTriangle = GetUserInputAsInt("Please input the number of Red Triangles: "); | ||
| int blueTriangle = GetUserInputAsInt("Please input the number of Blue Triangles: "); | ||
| int yellowTriangle = GetUserInputAsInt("Please input the number of Yellow Triangles: "); | ||
|
|
||
| Triangle triangle = new Triangle(redTriangle, blueTriangle, yellowTriangle); | ||
|
|
||
| return triangle; | ||
| } | ||
|
|
||
| private static string GetUserInputAsString(string message) | ||
| { | ||
| if (string.IsNullOrWhiteSpace(message)) | ||
| { | ||
| throw new ArgumentNullException(nameof(message)); | ||
| } | ||
|
|
||
| Console.Write(message); | ||
|
|
||
| // Get user input | ||
| string input = Console.ReadLine().Trim(); | ||
| while (string.IsNullOrEmpty(input)) | ||
| { | ||
| Console.WriteLine("please enter valid details"); | ||
| Console.Write(message); | ||
| input = Console.ReadLine(); | ||
| } | ||
|
|
||
| return input; | ||
| } | ||
|
|
||
| private static int GetUserInputAsInt(string message) //TODO: example had ints being nullable from input | ||
| { | ||
| string input = GetUserInputAsString(message); | ||
|
|
||
| while (!int.TryParse(input, out var _)) | ||
| { | ||
| Console.WriteLine("please enter valid details"); | ||
| input = GetUserInputAsString(message); | ||
| } | ||
|
|
||
| return int.Parse(input); | ||
| } | ||
| } | ||
| } | ||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,17 @@ | ||
| using System; | ||
| using Order.Management.ToyBlocks; | ||
| using System.Collections.Generic; | ||
| using System.Text; | ||
|
|
||
| namespace Order.Management | ||
| { | ||
| abstract class Order | ||
| public class Order | ||
| { | ||
| public string CustomerName { get; set; } | ||
| public string Address { get; set; } | ||
| public string DueDate { get; set; } | ||
| public string DueDate { get; set; } // TODO: should probably be DateTime | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
| public int OrderNumber { get; set; } | ||
| public List<Shape> OrderedBlocks { get; set; } | ||
| public List<Shape> OrderedBlocks { get; set; } = new List<Shape>(); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| public abstract void GenerateReport(); | ||
|
|
||
| public string ToString() | ||
| public override string ToString() | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer not to override the .net class |
||
| { | ||
| return "\nName: " + CustomerName + " Address: " + Address + " Due Date: " + DueDate + " Order #: " + OrderNumber; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: String interpolation better |
||
| } | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be parsing user input into
DateTime