Скачиваний:
70
Добавлен:
09.05.2014
Размер:
1.82 Кб
Скачать
import java.util.*;

public class Head
{
    public static void main(String[] args)
    {
       IncomingPoint[] obl = new IncomingPoint[3];
        obl[0] = new Sector();
        obl[1] = new Rectangle();
        obl[2] = new Triangle();

        /*System.out.println(Area.getVar());
        System.out.println(Area.getAuthor());
        System.out.println();*/

        double[][] A =
        {
            {4, 3},
            {5, -4},
            {-4, -4},
            {-3, 3},
            {-2, 2}
        };

        System.out.println("Введите R:");
        try
        {
            Scanner in = new Scanner(System.in);
            double bufR; //=-1;
            bufR = in.nextDouble();
            if (bufR>=0) Area.setR(bufR);
            else 
            {
                System.out.println("R введено неверно!");
                System.exit(0);
            }
            System.out.println();
        }
        catch(Exception e)
        {
            //e.toString();
            System.out.println("R введено неверно!");
            System.out.println();
            System.exit(0);
        }

         System.out.println("R = " + Area.getR());
         System.out.println("A = " + Arrays.deepToString(A));
         System.out.println();
		
		float count = 0;
		
        for (int j = 0; j < A.length; j++)
        {
            for (int i = 0; i < obl.length; i++)
            {
                if (obl[i].IncomingPoint(A[j][0],A[j][1]))
                {
                    CoordinateArea koor = Enum.valueOf(CoordinateArea.class, "Point"+(j+1));
                    System.out.println("Hit! " +koor.getAbbr());
					System.out.println(koor);
					++count;
                }
			
            }
        }
		System.out.println("\nHit ratio: " +count/A.length);
    }

}
Соседние файлы в папке лабораторная работа 1