You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
515 B
Go
38 lines
515 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
type Veicolo interface {
|
|
parti()
|
|
}
|
|
|
|
type Macchina struct {
|
|
NumeroPorte int
|
|
Propietario string
|
|
}
|
|
|
|
func (m *Macchina) parti() {
|
|
fmt.Println("La macchina e' partita")
|
|
}
|
|
|
|
type Camion struct {
|
|
Peso int
|
|
Propietario string
|
|
}
|
|
|
|
func (m *Camion) parti() {
|
|
fmt.Println("Il camion e' partito")
|
|
}
|
|
|
|
func muoviMezzo(v Veicolo) {
|
|
v.parti()
|
|
}
|
|
|
|
func main() {
|
|
m := &Macchina{NumeroPorte: 5, Propietario: "Boh"}
|
|
muoviMezzo(m)
|
|
|
|
c := &Camion{Peso: 1000, Propietario: "Boh"}
|
|
muoviMezzo(c)
|
|
}
|