add abstract class

This commit is contained in:
orange 2016-12-30 14:57:37 +01:00
parent 0013669ec2
commit f211d00400
2 changed files with 6 additions and 7 deletions

View File

@ -33,12 +33,7 @@ public class Archivio{
public void print(PrintStream ps){
for(Opera o: archivio){
if(o instanceof Libro)
((Libro) o).print(ps);
if(o instanceof Stampa)
((Stampa) o).print(ps);
if(o instanceof OperaMult)
((OperaMult) o).print(ps);
o.print(ps);
}
}

View File

@ -1,4 +1,6 @@
public class Opera{
import java.io.PrintStream;
abstract public class Opera{
public Opera(String autore, String titolo, int anno, String pos){
this.anno=anno;
this.autore=autore;
@ -26,6 +28,8 @@ public class Opera{
return autore.hashCode()*titolo.hashCode()*pos.hashCode()*anno;
}
abstract public void print(PrintStream ps);
protected int anno;
protected String autore;
protected String titolo;