Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Class Animale ' un animale
- Public Overridable Function FaiRumore() As String
- Return "Boh"
- End Function
- End Class
- Class Leone ' un animale che ruggisce
- Inherits Animale
- Public Overrides Function FaiRumore() As String
- Return "ruggisco"
- End Function
- End Class
- Class Elefante ' un animale che barrisce
- Inherits Animale
- Public Overrides Function FaiRumore() As String
- Return "barrisco"
- End Function
- End Class
- Class ElefanteIndiano
- Inherits Elefante
- Public Overrides Function FaiRumore() As String
- Return "barrisco, ma in indiano..."
- End Function
- End Class
- Class Cane
- Inherits Animale
- Public Overrides Function FaiRumore() As String
- Return "abbaio"
- End Function
- End Class
- Module Module1
- ' Modellare un sistema che visualizzi i versi fatti dagli animali inseriti in uno zoo
- Sub ProcessaZoo(zoo() As Animale)
- For Each animale As Animale In zoo
- Console.WriteLine(animale.FaiRumore())
- Next
- End Sub
- Sub Main()
- Dim leo As New Leone
- Dim ele As New Elefante
- Dim eli As New ElefanteIndiano
- Dim can As New Cane
- Dim animali() As Animale = {can, leo, ele, eli} ' array di animali
- ProcessaZoo(animali)
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement