Advertisement
Abdula_2314124

Untitled

Feb 26th, 2024
795
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace Looper
  6. {
  7.     class Book
  8.     {
  9.         private int _numberPage;
  10.         private int _totalPage;
  11.         private string _name;
  12.         private string[] _chapters;
  13.         public Book(int numberPage, int totalPage,
  14.             string name, string[] chapters)
  15.         {
  16.  
  17.             _numberPage = numberPage;
  18.             _totalPage = totalPage;
  19.             _name = name;
  20.             _chapters = chapters;
  21.         }
  22.  
  23.         public void ShowInfo()
  24.         {
  25.             Console.WriteLine(_numberPage);
  26.             Console.WriteLine(_totalPage);
  27.             Console.WriteLine(_name);
  28.             //for (int i = 0; i < _chapters.Length; i++)
  29.             //{
  30.             //    Console.WriteLine(_chapters[i]);
  31.             //}
  32.  
  33.             foreach (var chapter in _chapters)
  34.             {
  35.                 Console.WriteLine(chapter);
  36.             }
  37.         }
  38.  
  39.         public void UpdateName(string name)
  40.         {
  41.             _name = name;
  42.         }
  43.     }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement