Nuovi filtri

This commit is contained in:
Orange 2016-11-07 18:41:36 +01:00
parent 89723b37fa
commit 681e0f73a7
2 changed files with 36 additions and 1 deletions

View File

@ -37,6 +37,36 @@ public class Manager{
return max; return max;
} }
public FiguraGeometrica getAreaMin() {
FiguraGeometrica min = figure.get(0);
for (int i = 1; i < figure.size(); i++)
if (min.calcolaArea() > figure.get(i).calcolaArea())
min = figure.get(i);
return min;
}
public FiguraGeometrica getPerimetroMax(){
FiguraGeometrica max = figure.get(0);
for (int i = 1; i < figure.size(); i++)
if (max.calcolaPerimetro() < figure.get(i).calcolaPerimetro())
max = figure.get(i);
return max;
}
public FiguraGeometrica getPerimetroMin(){
FiguraGeometrica min = figure.get(0);
for (int i = 1; i < figure.size(); i++)
if (min.calcolaPerimetro() > figure.get(i).calcolaPerimetro())
min = figure.get(i);
return min;
}
public void print(PrintStream ps){ public void print(PrintStream ps){
for(FiguraGeometrica fg: figure) for(FiguraGeometrica fg: figure)
fg.print(ps); fg.print(ps);

View File

@ -1,11 +1,16 @@
import java.io.File; import java.io.File;
import java.util.Scanner; import java.util.Scanner;
import java.io.PrintStream;
public class Test { public class Test {
public static void main(String [] args) throws Exception{ public static void main(String [] args) throws Exception{
Scanner sc = new Scanner(new File("figure")); Scanner sc = new Scanner(new File("figure"));
Manager manager = new Manager(sc); Manager manager = new Manager(sc);
PrintStream ps = System.out;
manager.getAreaMax().print(System.out); ps.println("Figura con area maggiore");
manager.getAreaMax().print(ps);
ps.println("Figura con perimetro minore");
manager.getPerimetroMin().print(System.out);
} }
} }