Class Photo Album VB.Net Exercise - Visual Basic Programming Course


 Exercise

Class Photo Album

Objetive

Create a class "PhotoAlbum" with a private attribute "numberOfPages."

It should also have a public method "GetNumberOfPages", which will return the number of pages.

The default constructor will create an album with 16 pages. There will be an additional constructor, with which we can specify the number of pages we want in the album.

Create a class "BigPhotoAlbum" whose constructor will create an album with 64 pages.

Create a test class "AlbumTest" to create an album with its default constructor, one with 24 pages, a "BigPhotoAlbum" and show the number of pages that the three albums have.

Code

Imports System
Namespace December_19th__b_
    Class BigPhotoAlbum
        Inherits PhotoAlbum

        Public Sub New()
            numberOfPages = 64
        End Sub
    End Class
End Namespace

Namespace December_19th__b_
    Class AlbumTest
        Private Shared Sub Main()
            Dim debug As Boolean = False
            Dim myAlbum1 As PhotoAlbum = New PhotoAlbum()
            Console.WriteLine(myAlbum1.GetNumberOfPages())
            Dim myAlbum2 As PhotoAlbum = New PhotoAlbum(24)
            Console.WriteLine(myAlbum2.GetNumberOfPages())
            Dim myBigPhotoAlbum1 As BigPhotoAlbum = New BigPhotoAlbum()
            Console.WriteLine(myBigPhotoAlbum1.GetNumberOfPages())
            If debug Then Console.ReadLine()
        End Sub
    End Class
End Namespace


Juan A. Ripoll - Systems Tutorials and Programming Courses © 2024 All rights reserved.  Legal Conditions.