|
|
|
|
@ -53,3 +53,57 @@ $ make compile-noinline-<subproject>
|
|
|
|
|
$ make decomp-<subproject>
|
|
|
|
|
$ make decomp-noinline-<subproject>
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# Extra: Per chi non sa cosa sono le interfacce leggere prima questo
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
type Circle struct {
|
|
|
|
|
Radius float64
|
|
|
|
|
}
|
|
|
|
|
type Rectangle struct {
|
|
|
|
|
Width, Height float64
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Shape interface {
|
|
|
|
|
Area() float64
|
|
|
|
|
Perimeter() float64
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c Circle) Area() float64 {
|
|
|
|
|
return c.Radius * c.Radius * math.Pi
|
|
|
|
|
}
|
|
|
|
|
func (c Circle) Perimeter() float64 {
|
|
|
|
|
return 2 * c.Radius * math.Pi
|
|
|
|
|
}
|
|
|
|
|
func (c Circle) Curvature() float64 {
|
|
|
|
|
return 1 / c.Radius
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r Rectangle) Area() float64 {
|
|
|
|
|
return r.Width * r.Height
|
|
|
|
|
}
|
|
|
|
|
func (r Rectangle) Perimeter() float64 {
|
|
|
|
|
return 2 * r.Radius * math.Pi
|
|
|
|
|
}
|
|
|
|
|
func (r Rectangle) CornerCount() int {
|
|
|
|
|
if (r.Width == 0 && r.Height == 0) { return 0 }
|
|
|
|
|
if (r.Width == 0 || r.Height == 0) { return 2 }
|
|
|
|
|
return 4
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func AreaOverPerimeter(s Shape) float64 {
|
|
|
|
|
return s.Area() / s.Perimeter()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// c1 := Circle{ Radius: 5.0 }
|
|
|
|
|
c1 := Circle{ 5.0 }
|
|
|
|
|
|
|
|
|
|
// r1 := Rectangle{ Width: 2.0, Height: 3.0 }
|
|
|
|
|
r1 := Rectangle{ 2.0, 3.0 }
|
|
|
|
|
|
|
|
|
|
AreaOverPerimeter(c1)
|
|
|
|
|
AreaOverPerimeter(r1)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|