Advertisement
PawsonCz

Untitled

Dec 25th, 2021
1,465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.50 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Nauka
  4. {
  5.  
  6. class Books
  7.     {
  8.         static string bookTitle;
  9.         static string bookAuthor;
  10.         int publishYear;
  11.         string booklet = $"{bookTitle} {bookAuthor}";  
  12.         List<string> bookList = new List<string>();
  13.        
  14.  
  15.        
  16.         public string getBookData()
  17.         {
  18.             //this.bookTitle = bookTitle;
  19.             //this.bookAuthor = bookAuthor;
  20.            
  21.             Console.Write("Book\'s title:\t");
  22.             bookTitle = Console.ReadLine();
  23.             Console.Write("Book\'s Author:\t");
  24.             bookAuthor = Console.ReadLine();
  25.             booklet = $"{bookAuthor} {bookTitle}";
  26.             //bookList.Add(booklet);
  27.             Console.WriteLine($"{bookTitle}:\t{bookAuthor}");
  28.            
  29.  
  30.             return $"{bookAuthor} {bookTitle}";
  31.         }
  32.         public string printList()
  33.         {
  34.             bookList.Add(booklet);
  35.             Console.WriteLine("Nasza lista kasiążek zawiera:");
  36.             Console.WriteLine($"liczba książek na liście wynosi {bookList.Count}");
  37.             foreach (var book in bookList)
  38.             {
  39.                 Console.WriteLine(book);
  40.             }
  41.  
  42.             return booklet;
  43.         }
  44.        
  45.     }
  46.  
  47.     class Program
  48.     {
  49.         static void Main(string[] args)
  50.         {
  51.             var book1 = new Books();
  52.             var volumens = new Books();
  53.             book1.getBookData();
  54.             volumens.printList();
  55.        
  56.            
  57.         }
  58.     }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement