Ejercicio
Matriz de objetos: tabla
Objetivo
Cree una clase denominada "Table". Debe tener un constructor, indicando el ancho y alto de la placa. Tendrá un método "ShowData" que escribirá en la pantalla el ancho y la altura de la tabla. Cree una matriz que contenga 10 tablas, con tamaños aleatorios entre 50 y 200 cm, y muestre todos los datos.
Código
Imports System
Namespace ArrayOfObjects
Class Table
Private width, height As Single
Public Sub New()
End Sub
Public Sub New(ByVal width As Single, ByVal height As Single)
Me.width = width
Me.height = height
End Sub
Public Property Width As Single
Set(ByVal value As Single)
width = value
End Set
Get
Return width
End Get
End Property
Public Property Height As Single
Set(ByVal value As Single)
height = value
End Set
Get
Return height
End Get
End Property
Public Sub ShowData()
Console.WriteLine("Width: {0}, Heigth: {1}", width, height)
End Sub
End Class
Class TestTables
Private Shared Sub Main()
Dim debug As Boolean = False
Dim myTables As Table() = New Table(9) {}
Dim rnd As Random = New Random()
For i As Integer = 0 To 10 - 1
myTables(i) = New Table(rnd.[Next](50, 201), rnd.[Next](50, 201))
myTables(i).ShowData()
Next
If debug Then Console.ReadLine()
End Sub
End Class
End Namespace