public class Application {

public static void main(String[] args) {
Hesap h=HesapFactory.hesapOlustur("Vadeli Hesap");
System.out.println(h.getHesapTip());
h=HesapFactory.hesapOlustur("Vadesiz Hesap");
System.out.println(h.getHesapTip());
h=HesapFactory.hesapOlustur("Yatırım Hesabı");
System.out.println(h.getHesapTip());

h=HesapFactory.hesapOlustur("Vadeli Hesap");
System.out.println(h.getHesapTip());
} }

public interface Hesap {
public String getHesapTip();
}

public class HesapFactory {
public static Hesap hesapOlustur(String tip)
{
if(tip.equals("Vadesiz Hesap"))return new VadesizHesap();
else if (tip.equals("Vadeli Hesap")) return new VadeliHesap();
else if (tip.equals("Yatırım Hesabı")) return new YatirimHesap();
else throw new RuntimeException ("Hesap tipi belli değil");
}
}

public class VadeliHesap implements Hesap {

public String getHesapTip() {
return "Vadeli Hesap";
}

}

public class VadesizHesap implements Hesap {
public String getHesapTip() {
return "Vadesiz Hesap";
}
}

public class YatirimHesap implements Hesap {

public String getHesapTip() {
return "Yatırım Hesabı";
}
}