Please code in Java Programming Language
Here are some given Class:
IFan.class:
***********************************************************
import java.util.List; // // Decompiled by Procyon v0.5.36 // public interface IFan { void f1(final List<Fan> p0, final String p1); int f2(final List<Fan> p0, final double p1); void f3(final List<Fan> p0, final double p1); }
***********************************************************************************************
Main.class:
***********************************************************************************************
import java.util.ArrayList; import java.io.Reader; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Iterator; import java.util.List; // // Decompiled by Procyon v0.5.36 // public class Main { public static void OutputList(final List<Fan> c) { for (final Fan x : c) { System.out.printf("%-15s%-10.2f\n", x.getCode(), x.getPrice()); } } public static void main(final String[] args) throws Exception { final BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); final List<Fan> a = new ArrayList<Fan>(); System.out.print("Add more how many Fan: "); for (int n = Integer.parseInt(in.readLine()), i = 0; i < n; ++i) { System.out.println(""); System.out.print("Fan code: "); final String code = in.readLine(); System.out.print("Fan price: "); final double price = Double.parseDouble(in.readLine()); a.add(new Fan(code, price)); } a.add(0, new Fan("FS21", 70.0)); a.add(1, new Fan("KS20", 68.0)); a.add(2, new Fan("FF12", 52.0)); System.out.println(""); System.out.print("Enter test function (1-f1;2-f2;3-f3): "); final int c = Integer.parseInt(in.readLine()); final IFan j = (IFan)new MyFan(); double givenPrice = 0.0; String givenCode = ""; if (c == 1) { System.out.print("Enter given Fan code: "); givenCode = in.readLine(); } else if (c == 2 || c == 3) { System.out.print("Enter given Fan price: "); givenPrice = Double.parseDouble(in.readLine()); } System.out.println(""); System.out.println("OUTPUT:"); switch (c) { case 1: { j.f1(a, givenCode); OutputList(a); break; } case 2: { System.out.println(j.f2(a, givenPrice)); break; } case 3: { j.f3(a, givenPrice); OutputList(a); break; } } } }
********************************************************************************************************