Architechture 1
package practice2.business.abstracts;
public interface Logger {
void log(String message);
}
package practice2.business.concretes;
import practice2.business.abstracts.Logger;
public class EmailLogger implements Logger {
@Override
public void log(String message) {
System.out.println("Email loglandi: " + message);
}
}package practice2.business.concretes;
import practice2.business.abstracts.Logger;
public class SmsLogger implements Logger {
@Override
public void log(String message) {
System.out.println("Sms loglandi: " + message);
}
}package practice2.business.concretes;
import practice2.business.abstracts.Logger;
public class DatabaseLogger implements Logger {
@Override
public void log(String message) {
System.out.println("Database loglandi: " + message);
}
}package practice2.business.abstracts;
import practice2.entity.Customer;
import practice2.entity.Entity;
public interface Manager {
void add();
void delete();
}package practice2.business.concretes;
import practice2.business.abstracts.Logger;
import practice2.business.abstracts.Manager;
import practice2.entity.Customer;
public class CustomerManager implements Manager {
private Logger[] loggers;
private Customer customer;
public CustomerManager(Logger[] loggers, Customer customer) {
this.loggers = loggers;
this.customer = customer;
}
@Override
public void add() {
System.out.println("Customer added: " + customer.getName());
Utils.runLoggers(loggers, customer.getName());
}
@Override
public void delete() {
System.out.println("Customer deleted: " + customer.getName());
Utils.runLoggers(loggers, customer.getName());
}
}package practice2.business.concretes;
import practice2.business.abstracts.Logger;
public class Utils {
public static void runLoggers(Logger[] loggers, String message) {
for (Logger logger : loggers) {
logger.log(message);
}
}
}package practice2.entity;
public class Customer {
private int id;
private String name;
private String surname;
public Customer() {
}
public Customer(int id, String name, String surname) {
this.id = id;
this.name = name;
this.surname = surname;
}
public int getId() {
return id;
}
public Customer setId(int id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public Customer setName(String name) {
this.name = name;
return this;
}
public String getSurname() {
return surname;
}
public Customer setSurname(String surname) {
this.surname = surname;
return this;
}
}
Комментарии
Отправить комментарий