diff --git a/Examples/Cinema.cs b/Examples/Cinema.cs new file mode 100644 index 0000000..5b31c00 --- /dev/null +++ b/Examples/Cinema.cs @@ -0,0 +1,7 @@ +namespace Examples +{ + public class Cinema : ITicketing + { + public void Reserve() { } + } +} diff --git a/Examples/Concert.cs b/Examples/Concert.cs new file mode 100644 index 0000000..e05e955 --- /dev/null +++ b/Examples/Concert.cs @@ -0,0 +1,7 @@ +namespace Examples +{ + public class Concert : ITicketing + { + public void Reserve() { } + } +} diff --git a/Examples/EmailService.cs b/Examples/EmailService.cs new file mode 100644 index 0000000..24f63d3 --- /dev/null +++ b/Examples/EmailService.cs @@ -0,0 +1,7 @@ +public class EmailService : INotificationService +{ + public void Push(string message) + { + Console.WriteLine($"Sending Email: {message}"); + } +} diff --git a/Examples/Flight.cs b/Examples/Flight.cs new file mode 100644 index 0000000..9868aa1 --- /dev/null +++ b/Examples/Flight.cs @@ -0,0 +1,7 @@ +namespace Examples +{ + public class Flight : ITicketing + { + public void Reserve() { } + } +} diff --git a/Examples/INotificationService.cs b/Examples/INotificationService.cs new file mode 100644 index 0000000..105d544 --- /dev/null +++ b/Examples/INotificationService.cs @@ -0,0 +1,4 @@ +public interface INotificationService +{ + void Push(string message); +} \ No newline at end of file diff --git a/Examples/ITicketing.cs b/Examples/ITicketing.cs new file mode 100644 index 0000000..48548dc --- /dev/null +++ b/Examples/ITicketing.cs @@ -0,0 +1,4 @@ +public interface ITicketing +{ + public void Reserve(); +} \ No newline at end of file diff --git a/Examples/NotificationService.cs b/Examples/NotificationService.cs index 498d14d..a14fe63 100644 --- a/Examples/NotificationService.cs +++ b/Examples/NotificationService.cs @@ -1,15 +1,15 @@ -public class NotificationService() +public class NotificationService { - public ... Get(string type) + private readonly INotificationService _notificationService; + + + public NotificationService(INotificationService notificationService) { - if (type == "Email") - return new ...(); - else if (type == "SMS") - return new ...(); - //else if (type == "Push") - // return new ...(); + _notificationService = notificationService; + } - else - throw new ArgumentException("Invalid notification type."); + public void PushNotification(string message) + { + _notificationService.Push(message); } -} +} \ No newline at end of file diff --git a/Examples/SmsService.cs b/Examples/SmsService.cs new file mode 100644 index 0000000..da9d598 --- /dev/null +++ b/Examples/SmsService.cs @@ -0,0 +1,7 @@ +public class SmsService : INotificationService +{ + public void Push(string message) + { + Console.WriteLine($"Sending SMS: {message}"); + } +} diff --git a/Examples/Ticketing.cs b/Examples/Ticketing.cs index 9642fb9..0205c14 100644 --- a/Examples/Ticketing.cs +++ b/Examples/Ticketing.cs @@ -1,14 +1,14 @@ -public class TicketService +public class Ticketing { - public ... Get(string ticketType) + private readonly ITicketing _ticketing; + + public Ticketing(ITicketing ticketing) { - if (ticketType == "Movie") - return new ...(); - else if (ticketType == "Concert") - return new ...(); - else if (ticketType == "Flight") - return new ...(); - else - throw new ArgumentException("Invalid ticket type."); + _ticketing = ticketing; } -} + + public void ReserveTicket() + { + _ticketing.Reserve(); + } +} \ No newline at end of file