NikaBang

Недоделка

Nov 17th, 2025
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.79 KB | Gaming | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Reflection;
  5. using System.Security.Cryptography.X509Certificates;
  6.  
  7. internal class Program
  8. {
  9.     static void Main(string[] args)
  10.     {
  11.         const string CommandExit = "Exit";
  12.         const string CommandShowAllBooks = "1";
  13.         const string CommandAddBook = "2";
  14.         const string CommandRemoveBook = "3";
  15.         const string CommandSearchBook = "4";
  16.  
  17.         bool isRun = true;
  18.  
  19.         Library library = new Library();
  20.  
  21.         while (isRun)
  22.         {
  23.             Console.Clear();
  24.             Console.WriteLine($"{CommandShowAllBooks} - Показать все книги." +
  25.                 $"\n{CommandAddBook} - Добавить книгу." +
  26.                 $"\n{CommandRemoveBook} - Убрать книгу." +
  27.                 $"\n{CommandSearchBook} - Найти книгу." +
  28.                 $"\n{CommandExit} - Завершить программу.");
  29.  
  30.             switch (Console.ReadLine())
  31.             {
  32.                 case CommandShowAllBooks:
  33.                     library.ShowAllBooks();
  34.                     break;
  35.  
  36.                 case CommandAddBook:
  37.                     library.AddBook();
  38.                     break;
  39.  
  40.                 case CommandRemoveBook:
  41.                     library.RemoveBook();
  42.                     break;
  43.  
  44.                 case CommandSearchBook:
  45.                     library.SearchBook();
  46.                     break;
  47.  
  48.                 case CommandExit:
  49.                     isRun = false;
  50.                     break;
  51.  
  52.                 default:
  53.                     Console.WriteLine("Ошибка ввода.");
  54.                     break;
  55.             }
  56.         }
  57.  
  58.         Console.WriteLine("Программа завершена.");
  59.         Console.ReadKey();
  60.     }
  61. }
  62.  
  63. class Book
  64. {
  65.     public Book(string name, string releaseDate, string author)
  66.     {
  67.         Name = name;
  68.         ReleaseDate = releaseDate;
  69.         Author = author;
  70.     }
  71.  
  72.     public string Name { get; private set; }
  73.     public string ReleaseDate { get; private set; }
  74.     public string Author { get; private set; }
  75.  
  76.     public void ShowInfo()
  77.     {
  78.         Console.WriteLine($"Книга: {Name}. Автор: {Author}. Год издания: {ReleaseDate}.");
  79.     }
  80. }
  81.  
  82. class Library
  83. {
  84.     private List<Book> _books = new List<Book>();
  85.  
  86.     public Library()
  87.     {
  88.         _books.Add(new Book("", "", ""));
  89.         _books.Add(new Book("", "", ""));
  90.         _books.Add(new Book("", "", ""));
  91.         _books.Add(new Book("", "", ""));
  92.         _books.Add(new Book("", "", ""));
  93.     }
  94.  
  95.     public void ShowAllBooks()
  96.     {
  97.  
  98.     }
  99.  
  100.     public void AddBook()
  101.     {
  102.  
  103.     }
  104.  
  105.     public void RemoveBook()
  106.     {
  107.  
  108.     }
  109.  
  110.     public void SearchBook()
  111.     {
  112.  
  113.     }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment