lib: generic read_triangle
function
This commit is contained in:
parent
0fca39e716
commit
f28b29841a
1 changed files with 14 additions and 0 deletions
|
@ -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 }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue