public class CSVFactory {
public static void main(String arg[]) {
// GenerateCSVFile filetype= CSVFactoryClass
CSVFactoryClass factorydata = new CSVFactoryClass();
factorydata.callCSVfactory("detail").generateCSVFile();
CompanyWideReportCSV abc= new CompanyWideReportCSV();
abc= (CompanyWideReportCSV) factorydata.callCSVfactory("company");
abc.generateCSVFile();
}
}
interface GenerateCSVFile {
public String generateCSVFile();
}
class DetailReportCSV implements GenerateCSVFile{
public String generateCSVFile(){
System.out.println("pawan kumar------");
return "pawan";
}
public String generateCSVFilea(){
System.out.println("pawan kumar1111111111----------");
return "pawan";
}
}
class CompanyWideReportCSV implements GenerateCSVFile{
public String generateCSVFile(){
System.out.println("----------kumar----------");
return "kumar";
}
}
class CSVFactoryClass {
public GenerateCSVFile callCSVfactory(String csvType) {
if(csvType.equalsIgnoreCase("detail")){
return new DetailReportCSV();
}else if(csvType.equalsIgnoreCase("company")){
return new CompanyWideReportCSV();
} else {
return new DetailReportCSV();
}
}
}
No comments:
Post a Comment