class GravaImg{
Object img;
public void salvar(java.io.FileOutputStream out) throws IOException{
Utilidades.criaPng(out, img, 550, 400);
}
}
e tenha de implementar um modo de alterar o tamanho de gravação, mas conservar um default
seria melhor: *Re-criar um método:lass GravaImg{
Object img;
public void salvar(java.io.FileOutputStream out) throws IOException{
Utilidades.criaPng(out, img, 550, 400);
}
public void salvar(java.io.FileOutputStream out,int width,int height) throws IOException{
Utilidades.criaPng(out, img, width, height);
}
}
class GravaImg{
Object img;
private int width = 550;
private int height = 400;
public void salvar(java.io.FileOutputStream out,int width,int height) throws IOException{
Utilidades.criaPng(out, img, this.width, this.height);
}
public void setTamanho(int w, int h){
this.width = w;
this.height = h;
}
}
Tem diferença quanto a desempenho, legibilidade, flexibilidade?
Qual o padrão?
Quando usar qual modelo?