add inner class

This commit is contained in:
orange 2016-12-30 13:52:33 +01:00
parent a790300c6f
commit 30baec4990
6 changed files with 51 additions and 14 deletions

View File

@ -1,6 +0,0 @@
public class FiltroAutore implements FiltroStringa{
public String getString(Object obj){
return ((Opera) obj).getAutore();
}
}

View File

@ -1,3 +1,44 @@
public interface FiltroStringa{ public interface FiltroStringa{
String getString(Object obj); String getString(Object obj);
}
class FiltroSupporto implements FiltroStringa{
public String getString(Object obj){
if(obj instanceof OperaMult)
return ((OperaMult) obj).getSupporto();
else
return "";
}
}
class FiltroTecnica implements FiltroStringa{
public String getString(Object obj){
if(obj instanceof Stampa)
return ((Stampa) obj).getTecnica();
else
return "";
}
}
class FiltroAutore implements FiltroStringa{
public String getString(Object obj){
return ((Opera) obj).getAutore();
}
}
class FiltroTitolo implements FiltroStringa{
public String getString(Object obj){
return ((Opera) obj).getTitolo();
}
}
class FiltroPosizione implements FiltroStringa{
public String getString(Object obj){
return ((Opera) obj).getPos();
}
} }

View File

@ -1,6 +0,0 @@
public class FiltroTitolo implements FiltroStringa{
public String getString(Object obj){
return ((Opera) obj).getTitolo();
}
}

View File

@ -8,6 +8,10 @@ public class OperaMult extends Opera{
this.supporto=supporto; this.supporto=supporto;
} }
public String getSupporto(){
return supporto;
}
public int hashCode(){ public int hashCode(){
return super.hashCode()*supporto.hashCode(); return super.hashCode()*supporto.hashCode();
} }

View File

@ -8,6 +8,10 @@ public class Stampa extends Opera{
this.tecnica=tecnica; this.tecnica=tecnica;
} }
public String getTecnica(){
return tecnica;
}
public int hashCode(){ public int hashCode(){
return super.hashCode()*tecnica.hashCode(); return super.hashCode()*tecnica.hashCode();
} }

View File

@ -13,10 +13,10 @@ public class Test{
System.out.println("****"); System.out.println("****");
arch.filtroStringa(new FiltroAutore(), "Autore1").print(System.out); arch.filtroStringa(new FiltroAutore(), "Autore1").filtroStringa(new FiltroPosizione(), "4D").print(System.out);
System.out.println("****"); System.out.println("****");
arch.filtroAnno(2000).print(System.out); arch.filtroStringa(new FiltroTecnica(), "Pergamena").filtroAnno(1999).print(System.out);
} }
} }