forked from ardanlabs/gotraining
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template1.go
31 lines (22 loc) · 1.01 KB
/
template1.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// All material is licensed under the Apache License Version 2.0, January 2004
// http://www.apache.org/licenses/LICENSE-2.0
// https://play.golang.org/p/Qe3dhDTwzX
// Declare a struct type named Point with two fields, X and Y of type int.
// Implement a factory function for this type and a method that accepts
// this type and calculates the distance between the two points. What is
// the nature of this type?
package main
// Add imports.
// Declare struct type named Point that represents a point in space.
// Declare a function named New that returns a Point based on X and Y
// positions on a graph.
// Declare a method named Distance that finds the length of the hypotenuse
// between two points. Pass one point in and return the answer.
// Formula is the square root of (x2 - x1)^2 + (y2 - y1)^2
// Use the math.Pow and math.Sqrt functions.
// main is the entry point for the application.
func main() {
// Declare the first point.
// Declare the second point.
// Calculate the distance and display the result.
}