// ==========================================================================
// $Id: norm2.go,v 1.1 2014/03/31 21:34:24 jlang Exp $
// CSI2120 GO: Methods
// ==========================================================================
// (C)opyright:
//
//   Jochen Lang
//   EECS, University of Ottawa
//   800 King Edward Ave.
//   Ottawa, On., K1N 6N5
//   Canada. 
//   http://www.eecs.uottawa.ca
// 
// Creator: Jochen Lang (based on example by R. Laganiere)
// Email:   jlang@eecs.uottawa.ca
// ==========================================================================
// $Log: norm2.go,v $
// Revision 1.1  2014/03/31 21:34:24  jlang
// "Added examples for file I/O, methods, interfaces"
//
// ==========================================================================
package main

import (
	"fmt"
	"math"
)

type Point struct {
	x float64
	y float64
}

// func (_ receiver_type) methodName(parameter_list) (return_value_list) { ... }
func (pt *Point) norm() float64 {
	return math.Sqrt(pt.x*pt.x + pt.y*pt.y)
}

func main() {
	a := Point{2.,4.}
	n := a.norm()
	fmt.Printf("2-Norm = %f\n", n)
}
