1. Course
  2. OOP
  3. Photo book class

Photo book class


Last updated: 8/26/2020 Difficulty: Intermediate

Create a C# program to manage a photo book using object-oriented programming.

To start, create a class called PhotoBook with a private attribute numPages of type int. It must also have a public method GetNumberPages that will return the number of photo book 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.

There is also a BigPhotoBook class whose constructor will create an album with 64 pages.

Finally create a PhotoBookTest class to perform the following actions:

  • Create a default photo book and show the number of pages
  • Create a photo book with 24 pages and show the number of pages
  • Create a large photo book and show the number of pages

Input


                    
                    

Output

16
24
64

Solution

OOP

4 / 8

Android App


Practice C# anywhere with the free app for Android devices.

Android App

Exercises C# by difficulty


Learn C# at your own pace, the exercises are ordered by difficulty.

Make a donation


Your donations support our work and contribute to the maintenance of the app.

Advertising