Skip to content

Instantly share code, notes, and snippets.

View Mishco's full-sized avatar
🎯
Focusing

Michal Slovík Mishco

🎯
Focusing
View GitHub Profile
@Bean
public Store store() {
Store store = new Store();
store.setItem(item1());
return store;
}
public class Store {
private Item item;
public Store() {
item = new ItemImpl1();
}
}
public class Store {
private Item item;
public Store(Item item) {
public class WeatherTracker {
public String currentConditions;
public void setCurrentConditions(String weatherDescription) {
this.currentConditions = weatherDescription;
}
public void notify(Notifier notifier) {
notifier.alertWeatherConditions(currentConditions);
}
public interface Notifier {
void alertWeatherConditions(String weatherConditions);
}
public class Email implements Notifier {
@Override
public void alertWeatherConditions(String weatherConditions) {
if (weatherConditions == "sunny");
System.out.print("It is sunny");
}
public class WeatherTracker {
public String currentConditions;
private Phone phone;
private Emailer emailer;
public WeatherTracker() {
phone = new Phone();
emailer = new Emailer();
}
public class CurrentAccount extends Account implements Deposable, Withdrawable {
@Override
protected void deposit(BigDecimal amount) {
// Deposit into CurrentAccount
}
@Override
protected void withdraw(BigDecimal amount) {
// Withdraw from CurrentAccount
}
}
public interface Depositable {
void deposit(BigDecimal amount);
}
public interface Withdrawable {
void withdraw(BigDecimal amount);
}
public abstract class Account {
// keep for private
}
public abstract class Account {
protected abstract void deposit(BigDecimal amount);
protected abstract void withdraw(BigDecimal amount);
}
/**
* Empty method
*/
public class FixedTermDepositAccount extends Account {
public class BasicPrinter implements Printer {
@Override
public boolean print() {
//Logic for printing
return true;
}
}
public class BasicScanner implements Scan {
@Override
public boolean scan() {
public interface Scan {
boolean scan();
}
public interface Printer {
boolean print();
}
public interface Fax {
boolean fax();
}
public class MultifunctionalFaxPrinter implements Printer, Fax, Scan {