internal static void Main() { // Create book var book = new Book("Microsoft", "CLR via C# 4", 10); book.Display(); Console.WriteLine(new string('-', 60)); // Create video var video = new Video("Stanley Kubrick", "A Clockwork Orange", 23, 92); video.Display(); Console.WriteLine(new string('-', 60)); // Make book borroable, then borrow and display Console.WriteLine("Making book borrowable:"); var borrowableBook = new Borrowable(book); borrowableBook.BorrowItem("Nikolay Kostov"); borrowableBook.BorrowItem("Ivaylo Kenov"); borrowableBook.Display(); Console.WriteLine(new string('-', 60)); // Make video borrowable, then borrow and display Console.WriteLine("Making video borrowable:"); var borrowableVideo = new Borrowable(video); borrowableVideo.BorrowItem("Nikolay Kostov"); borrowableVideo.BorrowItem("Ivaylo Kenov"); borrowableVideo.Display(); Console.WriteLine(new string('-', 60)); // Make only video buyable Console.WriteLine("Making video buyable:"); var buyableAndBorrowableVideo = new Buyable(borrowableVideo, 15); buyableAndBorrowableVideo.Display(); Console.WriteLine(new string('-', 60)); }
static void Main(string[] args) { Pizza pizza1 = new ItalianPizza(); pizza1 = new CheesePizza(new TomatoPizza(pizza1)); // итальянская пицца с томатами Console.WriteLine("Название: {0}", pizza1.Name); Console.WriteLine("Цена: {0}", pizza1.GetCost()); Console.WriteLine("Ингридиенты: {0}", pizza1.GetIngridients().Aggregate((s, p) => string.Concat(s, ", ", p))); // Create video Video video = new Video("Spielberg", "Jaws", 23, 92); video.Display(); // Make video borrowable, then borrow and display Console.WriteLine("\nMaking video borrowable:"); Borrowable borrowvideo = new Borrowable(video); borrowvideo.BorrowItem("Customer #1"); borrowvideo.BorrowItem("Customer #2"); borrowvideo.Display(); GunSample(); Console.WriteLine("Agile Book Decorator Sample"); AgileBookSamples.Modem.ModemDecoratorTest.Test(); Console.WriteLine(""); Console.ReadLine(); }
static void Main() { // Create book Book book = new Book("Worley", "Inside ASP.NET", 10); book.Display(); // Create video Video video = new Video("Spielberg", "Jaws", 23, 92); video.Display(); // Make video borrowable, then borrow and display Console.WriteLine("\nMaking video borrowable:"); Borrowable borrowvideo = new Borrowable(video); borrowvideo.BorrowItem("Customer #1"); borrowvideo.BorrowItem("Customer #2"); borrowvideo.Display(); // Wait for user Console.ReadKey(); }
static void Main(string[] args) { var book1 = new Book("Book 1", 5); book1.Display(); var book2 = new Book("Book 2", 7); var borrowBook = new Borrowable(book2); borrowBook.Borrow("User 1"); borrowBook.Borrow("User 2"); borrowBook.Display(); Console.ReadKey(); }
public static void Run() { Console.WriteLine("Real World: This real-world code demonstrates the Decorator pattern in which 'borrowable' functionality is added to existing library items (books and videos)."); Book book = new Book("Worley", "Inside ASP.NET", 10); book.Display(); Video video = new Video("Spielberg", "Jaws", 23, 92); video.Display(); Console.WriteLine("\nMaking video borrowable"); Borrowable borrowvideo = new Borrowable(video); borrowvideo.BorrowItem("Customer #1"); borrowvideo.BorrowItem("Customer #2"); borrowvideo.Display(); /* * Book------ * Author: Worley * Title: Inside ASP.NET # Copies: 10 # # Video ----- # Director: Spielberg # Title: Jaws # Copies: 23 # Playtime: 92 # # # Making video borrowable: # # Video---- - # Director: Spielberg # Title: Jaws # Copies: 21 # Playtime: 92 # # borrower: Customer #1 # borrower: Customer #2 */ }
static void Main(string[] args) { Console.WriteLine("Sans decorator!"); Book book = new Book("J. K. Rowling", "Harry Potter IV", 10); book.Display(); Video video = new Video("Peter Jackson", "Seigneur des anneaux II", 20, 135); video.Display(); Borrowable borrowable = new Borrowable(video); borrowable.Borrow("Elias"); borrowable.Display(); }
internal static void Main() { // Create book var book = new Book("Microsoft", "CLR via C# 3", 10); book.Display(); // Create video var video = new Video("Stanley Kubrick", "A Clockwork Orange", 23, 92); video.Display(); // Make video borrowable, then borrow and display Console.WriteLine("\nMaking video borrowable:"); var borrowableVideo = new Borrowable(video); borrowableVideo.BorrowItem("Nikolay Kostov"); borrowableVideo.BorrowItem("George Georgiev"); borrowableVideo.Display(); }
public static void Main() { var book = new Book("Book Author", "Book Title", 5); book.Display(); var video = new Video("Video Author", "Video Title", 120, 3); video.Display(); Console.WriteLine("\nMaking video borrowable:"); Borrowable borrowVideo = new Borrowable(video); borrowVideo.BorrowItem("Customer #1"); borrowVideo.BorrowItem("Customer #2"); borrowVideo.Display(); }
static void Main(string[] args) { var book = new Book("Inside ASP.NET", "Worley"); book.Display(); var video = new Video("Spielberg", 92); video.Display(); Console.WriteLine("------"); var borrowvideo = new Borrowable(video); borrowvideo.BorrowItem("Customer #1"); borrowvideo.BorrowItem("Customer #2"); borrowvideo.Display(); }
static void Main() { // First example /* Beverage beverage = new Espresso(); Console.WriteLine(beverage.getDescription() + " $" + beverage.Cost()); Beverage beverage1 = new DarkRoast(); beverage1 = new Mocha(beverage1); beverage1 = new Mocha(beverage1); Console.WriteLine(beverage1.getDescription() + " $" + beverage1.Cost()); */ // Second example // Create ConcreteComponent and two Decorators /* ConcreteComponent c = new ConcreteComponent(); ConcreteDecorator d1 = new ConcreteDecorator(); ConcreteDecoratorB d2 = new ConcreteDecoratorB(); // Link decorators d1.SetComponent(c); d2.SetComponent(d1); d2.Operation(); */ // Third example // Create book Book book = new Book("Worley", "Inside ASP.NET", 10); book.Display(); // Create video Video video = new Video("Spielberg", "Jaws", 23, 92); video.Display(); // Make video borrowable, then borrow and display Console.WriteLine("\nMaking video borrowable:"); Borrowable borrowvideo = new Borrowable(video); borrowvideo.BorrowItem("Customer #1"); borrowvideo.BorrowItem("Customer #2"); borrowvideo.Display(); }
static void Main() { /* * Structural */ // Create ConcreteComponent and two Decorators StructuralConcreteComponent c = new StructuralConcreteComponent(); ConcreteDecoratorA d1 = new ConcreteDecoratorA(); ConcreteDecoratorB d2 = new ConcreteDecoratorB(); // Link Decorators d1.SetComponent(c); d2.SetComponent(d1); // Call decorators operation d2.Operation(); /* * Real World */ // Create a book Book book = new Book("Cantu, Jeremy", "My Life as a Person", 12345); book.Display(); // Create a video Video video = new Video("Tarantino, Quentin", "Jeremy's Life", 54321, 60); video.Display(); // Make video borrow-able, then borrow and display Console.WriteLine("Making video borrow-able"); Borrowable borrowableVideo = new Borrowable(video); borrowableVideo.BorrowItem("Customer #1"); borrowableVideo.BorrowItem("Customer #2"); borrowableVideo.Display(); }
static void Main(string[] args) { var book = new Book("JK Rowling", "Harry Potter", 10); book.Display(); var video = new Video("George Lucas", "Star Wars", 30, 120); video.Display(); Console.WriteLine("\nMaking video borrowable:"); var borrowvideo = new Borrowable(video); borrowvideo.BorrowItem("Customer #1"); borrowvideo.BorrowItem("Customer #2"); borrowvideo.Display(); Console.ReadKey(); }
/// <summary> /// Entry point into console application. /// </summary> static void Main() { // Create book Book book = new Book("Worley", "Inside ASP.NET", 10); book.Display(); // Create video Video video = new Video("Spielberg", "Jaws", 23, 92); video.Display(); // Make video borrowable, then borrow and display Console.WriteLine("\nMaking video borrowable:"); Borrowable borrowvideo = new Borrowable(video); borrowvideo.BorrowItem("Customer #1"); borrowvideo.BorrowItem("Customer #2"); borrowvideo.Display(); // Wait for user Console.ReadKey(); }
public static void Main() { // Create book var book = new Book("Microsoft", "CLR via C# 4", 10); book.Display(); Console.WriteLine(new string('-', 60)); // Create video var video = new Video("Stanley Kubrick", "A Clockwork Orange", 23, 92); video.Display(); Console.WriteLine(new string('-', 60)); // Make book borroable, then borrow and display Console.WriteLine("Making book borrowable:"); var borrowableBook = new Borrowable(book); borrowableBook.BorrowItem("Nikolay Kostov"); borrowableBook.BorrowItem("Ivaylo Kenov"); borrowableBook.Display(); Console.WriteLine(new string('-', 60)); // Make video borrowable, then borrow and display Console.WriteLine("Making video borrowable:"); var borrowableVideo = new Borrowable(video); borrowableVideo.BorrowItem("Nikolay Kostov"); borrowableVideo.BorrowItem("Ivaylo Kenov"); borrowableVideo.Display(); Console.WriteLine(new string('-', 60)); // Make only video buyable Console.WriteLine("Making video buyable:"); var buyableAndBorrowableVideo = new Buyable(borrowableVideo, 15); buyableAndBorrowableVideo.Display(); Console.WriteLine(new string('-', 60)); }
static void Main(string[] args) { Book book = new Book("Worley", "Inside ASP.NET", 10); book.Display(); // Crear video Video video = new Video("Spielberg", "Jaws", 23, 92); video.Display(); // Hacer que el video sea prestable, luego tomar prestado y mostrarlo Console.WriteLine("\nMaking video borrowable:"); Borrowable borrowvideo = new Borrowable(video); borrowvideo.BorrowItem("Customer #1"); borrowvideo.BorrowItem("Customer #2"); borrowvideo.Display(); // Esperando usuario Console.ReadKey(); }
internal static void Main() { // Create book var book = new Book("Microsoft", "CLR via C# 3", 10); book.Display(); // Create video var video = new Video("Stanley Kubrick", "A Clockwork Orange", 23, 92); video.Display(); // Make video borrowable, then borrow and display Console.WriteLine("\nMaking video borrowable:"); var borrowableVideo = new Borrowable(video); borrowableVideo.BorrowItem("Georgi Bastunov"); borrowableVideo.BorrowItem("Pesho Georgiev"); borrowableVideo.Display(); var game = new Game("Unknown", "League of Legends", 23, 100); var borrowableGame = new Borrowable(game); borrowableGame.Display(); }