Answer to Question #166909 in C# for Habib

Question #166909

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 lbum. 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.


1
Expert's answer
2021-02-25T17:14:55-0500
using System;

namespace AlbumTest
{
    public class PhotoAlbum
    {
        private int numberOfPages;

        public PhotoAlbum()
        {
            numberOfPages = 16;
        }

        public PhotoAlbum(int pages)
        {
            numberOfPages = pages;
        }

        public int GetNumberOfPages() { return numberOfPages; }
    }

    public class BigPhotoAlbum
    {
        private int numberOfPages;

        public BigPhotoAlbum()
        {
            numberOfPages = 64;
        }

        public int GetNumberOfPages() { return numberOfPages; }
    }

    class AlbumTest
    {
        static void Main(string[] args)
        {
            PhotoAlbum    album1 = new PhotoAlbum();
            PhotoAlbum    album2 = new PhotoAlbum(24);
            BigPhotoAlbum album3 = new BigPhotoAlbum();

            Console.WriteLine("The 'album1' has {0} pages", album1.GetNumberOfPages());
            Console.WriteLine("The 'album2' has {0} pages", album2.GetNumberOfPages());
            Console.WriteLine("The 'album3' has {0} pages", album3.GetNumberOfPages());
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS