Advertisement
Nicksed

Untitled

Jun 7th, 2023
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. // Which SOLID principle is violated here?
  2. class EmailSender {
  3.     public void sendEmail(String recipient, String message) {
  4.         // Code to send email
  5.         System.out.println("Sending email to: " + recipient);
  6.         System.out.println("Message: " + message);
  7.     }
  8. }
  9.  
  10. class NotificationService {
  11.     private EmailSender emailSender;
  12.  
  13.     public NotificationService() {
  14.         emailSender = new EmailSender();
  15.     }
  16.  
  17.     public void sendNotification(String recipient, String message) {
  18.         emailSender.sendEmail(recipient, message);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement