Created
October 11, 2015 13:53
-
-
Save achilles42/48e25424e1e36e2b432f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Rectangle struct { | |
length, width int | |
} | |
func (r *Rectangle) Area() int { | |
return r.length * r.width | |
} | |
func (r *Rectangle) per() int { | |
return 2 * (r.length + r.width) | |
} | |
type Square struct { | |
rectangle := new(Rectangle) //creating the reference for rectange struct | |
length int | |
} | |
func (s *Square) Area() int { | |
return s.length * s.length | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment