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.
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());
}
}
}
Comments
Leave a comment