using System; using System.Collections.Generic; namespace BookExample { public class Book { public string Title { get; private set; } public string Author { get; private set; } public decimal Price { get; private set; } public Book(string title, string author, decimal price) { Title = title; Author = author; Price = price; } public void DisplayDetails() { Console.WriteLine($"Title: {Title}"); Console.WriteLine($"Author: {Author}"); Console.WriteLine($"Price: ${Price:F2}"); } } public class Librarian { private List _books; public Librarian() { _books = new List(); } public void AddBook(Book book) { _books.Add(book); Console.WriteLine($"Added book: {book.Title}"); } public void DisplayAllBooks() { if (_books.Count == 0) { Console.WriteLine("No books in the library."); return; } Console.WriteLine("Books in the library:"); foreach (var book in _books) { book.DisplayDetails(); Console.WriteLine(); } } } // we should use the Dip principe here by adding interface item instead of make the librian deal with just books but its just a simple program to demonstrate the SRP class Program { static void Main(string[] args) { Librarian librarian = new Librarian(); Book book1 = new Book("The Great Gatsby", "F. Scott Fitzgerald", 12.99m); Book book2 = new Book("1984", "George Orwell", 9.99m); Book book3 = new Book("To Kill a Mockingbird", "Harper Lee", 10.99m); librarian.AddBook(book1); librarian.AddBook(book2); librarian.AddBook(book3); librarian.DisplayAllBooks(); } } }