Ejercicio
Catálogo
Objetivo
Cree el diagrama de clases y, a continuación, con Visual Studio, un proyecto y las clases correspondientes para una utilidad de catálogo:
Podrá almacenar información sobre archivos de música, películas y programas informáticos.
Para cada artículo, debe almacenar: nombre, código, categoría y tamaño. Para las películas también debe tener el director, el actor principal y la actriz principal. Para archivos de música, el cantante y la duración (en segundos). Para música y películas debe tener un método "Play" (aún no implementado) y también un método "RetrieveInformation", que (en una versión posterior) se conectará a un servidor de Internet para obtener información al respecto.
Use la herencia si es necesario. En "Main", cree matrices de cada tipo de objeto.
Código
Imports System
Namespace Catalog
Class TestItem
Private Shared Sub Main()
Dim myFilms As Film() = New Film(2) {}
Dim myMusic As Music() = New Music(2) {}
Dim myComputerProgram As ComputerProgram() = New ComputerProgram(2) {}
End Sub
End Class
Public Class Item
Protected name As String
Protected code As String
Protected category As String
Protected size As String
Public Sub New()
End Sub
Public Sub New(ByVal name As String, ByVal code As String, ByVal category As String, ByVal size As String)
Me.name = name
Me.code = code
Me.category = category
Me.size = size
End Sub
Public Property Name As String
Get
Return name
End Get
Set(ByVal value As String)
name = value
End Set
End Property
Public Property Code As String
Get
Return code
End Get
Set(ByVal value As String)
code = value
End Set
End Property
Public Property Category As String
Get
Return category
End Get
Set(ByVal value As String)
category = value
End Set
End Property
Public Property Size As String
Get
Return size
End Get
Set(ByVal value As String)
size = value
End Set
End Property
End Class
Public Class Film
Inherits Item
Protected director As String
Protected mainActor, mainActress As String
Public Sub New()
End Sub
Public Sub New(ByVal director As String, ByVal mainActor As String, ByVal mainActress As String)
Me.director = director
Me.mainActor = mainActor
Me.mainActress = mainActress
End Sub
Public Property Director As String
Get
Return director
End Get
Set(ByVal value As String)
director = value
End Set
End Property
Public Property MainActor As String
Get
Return mainActor
End Get
Set(ByVal value As String)
mainActor = value
End Set
End Property
Public Property MainActress As String
Get
Return mainActress
End Get
Set(ByVal value As String)
mainActress = value
End Set
End Property
Public Sub Play()
End Sub
Public Sub RetrieveInformation()
End Sub
End Class
Public Class Music
Inherits Item
Protected singer As String
Protected length As Integer
Public Sub New()
End Sub
Public Sub New(ByVal singer As String, ByVal length As Integer)
Me.singer = singer
Me.length = length
End Sub
Public Property Singer As String
Get
Return singer
End Get
Set(ByVal value As String)
singer = value
End Set
End Property
Public Property Lenght As Integer
Get
Return length
End Get
Set(ByVal value As Integer)
length = value
End Set
End Property
Public Sub Play()
End Sub
Public Sub RetrieveInformation()
End Sub
End Class
Public Class ComputerProgram
Inherits Item
End Class
End Namespace