import javax.swing.*; public class TreatmentPlantTest { public static void main(String[] args) { Town[] towns = new Town[4]; towns[0] = new Town("Boxboro", 1.0E9, 1.0E7, 0.50, null, null); towns[1] = new Town("Sudbury", 2.0E9, 5.0E7, 0.65, null, null); Town[] up2 = { towns[0], towns[1] }; towns[2] = new Town("Acton", 4.0E9, 1.1E8, 0.40, null, up2); Town[] up3 = { towns[2] }; towns[3] = new Town("Concord", 2.5E9, 2.5E8, 0.00, null, up3); String input; while (true) { for (int i = 0; i < towns.length; i++) { input = JOptionPane.showInputDialog( "Enter plant type (1-3) for " + towns[i].getTown()); int plantType = Integer.parseInt(input); input = JOptionPane.showInputDialog("Enter fraction removed (0-1.0) for " + towns[i].getTown()); double x = Double.parseDouble(input); if (plantType == 1) towns[i].setTreatmentPlant(new PlantType1(towns[i], x)); else if (plantType == 2) towns[i].setTreatmentPlant(new PlantType2(towns[i], x)); else if (plantType == 3) towns[i].setTreatmentPlant(new PlantType3(towns[i], x)); } for (int i = 0; i < towns.length; i++) { double concentration = towns[i].calculateConcentration(); System.out.println(); System.out.println( towns[i].getTown() + " concentration: " + concentration); if (concentration > TreatmentPlant.MAX_CONCENTRATION) System.out.println(" Concentration over regulatory limit"); double cost= towns[i].getTreatmentPlant().getCost(); System.out.println(" Cost :"+ cost); double area= towns[i].getTreatmentPlant().getArea(); System.out.println(" Area :"+ area); double fracRemoved= towns[i].getTreatmentPlant().x; System.out.println(" Fraction removed :"+ fracRemoved); double maxRemoved= towns[i].getTreatmentPlant().getMaxRemoved(); System.out.println(" Max fraction removed :"+ maxRemoved); } input = JOptionPane.showInputDialog("Another run (y/n)? "); if (!input.equals("y")) break; } System.exit(0); } }