created rectangle struct and IsRect()
defined what a rectangle is and also implemented IsRect(), which returns a bool whether the coordinates given make a rectangle or not. Tests were written for IsRect()
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"s.mcquay.me/dm/rect"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r := rect.Rectangle{
|
||||
P1: rect.Point{1, 1},
|
||||
P2: rect.Point{1, 2},
|
||||
P3: rect.Point{2, 1},
|
||||
P4: rect.Point{2, 2},
|
||||
}
|
||||
fmt.Println(r.IsRect())
|
||||
r1 := rect.Rectangle{
|
||||
P1: rect.Point{0, 0},
|
||||
P2: rect.Point{0, 1},
|
||||
P3: rect.Point{1, 0},
|
||||
P4: rect.Point{1, 1},
|
||||
}
|
||||
fmt.Println(r1.IsRect())
|
||||
r1 := rect.Rectangle{
|
||||
P1: rect.Point{0, 0},
|
||||
P2: rect.Point{0, 1},
|
||||
P3: rect.Point{1, 0},
|
||||
P4: rect.Point{1, 1},
|
||||
}
|
||||
fmt.Println(r1.IsRect())
|
||||
}
|
||||
Reference in New Issue
Block a user