From 8e80af2714f9ab2a29e549558d2ddb1d236fe319 Mon Sep 17 00:00:00 2001 From: Nikita Goltsev Date: Fri, 2 Aug 2024 19:11:15 +0300 Subject: [PATCH] WithBaseView of PatterMachesClass --- PatternMatching/Book.cs | 8 ++++---- PatternMatching/LibraryClass.cs | 22 +++++++++++++++++++++- PatternMatching/Program.cs | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/PatternMatching/Book.cs b/PatternMatching/Book.cs index 806f980..bb3a2a8 100644 --- a/PatternMatching/Book.cs +++ b/PatternMatching/Book.cs @@ -8,10 +8,10 @@ namespace PatternMatching { public class Book { - public string Title; - public string Author; - public uint PublishedYear; - public uint ISBN; + public string Title { get; set; } = "NoName"; + public string Author { get; set; } = ""; + public uint PublishedYear { get; set; } = 0; + public uint ISBN { get; set; } = 0; public Book(string Title, string Author,uint Year, uint ISBN) { diff --git a/PatternMatching/LibraryClass.cs b/PatternMatching/LibraryClass.cs index 7054c34..4a3899a 100644 --- a/PatternMatching/LibraryClass.cs +++ b/PatternMatching/LibraryClass.cs @@ -50,7 +50,27 @@ public void RemoveBook(int isbn) } } - List SearchBooks(string searchTerm) { return new List(); } + List SearchBooks(string searchTerm) + { + List result = new List(); + + /* + foreach (Book book in this.booksInLib) + { + if (book is Book { Title: searchTerm }) + { + result.Add(book); + } + } + */ + return result; + } + /* + int GetId(string name, string autor) => (id) switch + { + (this.booksInLib., ) + } + */ } } diff --git a/PatternMatching/Program.cs b/PatternMatching/Program.cs index 82024a8..f295b15 100644 --- a/PatternMatching/Program.cs +++ b/PatternMatching/Program.cs @@ -8,7 +8,7 @@ public static void Main(string[] args) { LibraryClass mainObj = new LibraryClass(); - + } }