diff --git a/lib/geometry/src/lib.rs b/lib/geometry/src/lib.rs index 8c17586..745d165 100644 --- a/lib/geometry/src/lib.rs +++ b/lib/geometry/src/lib.rs @@ -99,3 +99,17 @@ pub fn read_point(prompt: &str) -> Point { y: coords[1], } } + +// Reads the coordinates of the vertices for a triangle +// and constructs a `triangle` object +pub fn read_triangle(name: &str) -> Triangle { + println!( + "Enter the coordinates for the three vertices of triangle {}:", + name + ); + let p1 = read_point("First vertex (x y):"); + let p2 = read_point("Second vertex (x y):"); + let p3 = read_point("Third vertex (x y):"); + + Triangle { p1, p2, p3 } +}