Université de Bordeaux

Licence Sciences & Technologies - Semestre 4

J1IN4W01 : Programmation 2



TD3

Classe TestPoint2DCartesien

public class TestPoint2DCartesien {

    private static void affichePoint2DCartesien(String pointId, Point2DCartesien p) {
        System.out.println(pointId + " C" + p + " P(" + p.getModule() + ", " + p.getArgument() + ")");  
    }

    private static void usage() {
        System.err.println("java TestPoint2DCartesien abs1 ord1 abs2 ord2 rapport-homothetie angle-rotation");
        System.exit(1);
    }

    public static void main(String[] args) {
        if (args.length != 6)
            usage();

        Point2DCartesien p1 = new Point2DCartesien(Double.parseDouble(args[0]),
                                                   Double.parseDouble(args[1]));

        Point2DCartesien p2 = new Point2DCartesien(Double.parseDouble(args[2]),
                                                   Double.parseDouble(args[3]));

        double rapport = Double.parseDouble(args[4]);
        double angle = Double.parseDouble(args[5]);

        double module = p1.getModule();
        double argument = p1.getArgument();
                                                
        affichePoint2DCartesien("p1", p1);
        affichePoint2DCartesien("p2", p2);

        System.out.println("distance entre p1 et p2 " + Point2DCartesien.distance(p1, p2));

        p1.homothetie(rapport);
        System.out.println("p1 apres homothetie de centre O et de rapport " + rapport + " : "  + p1);

        p2.rotation(angle);
        System.out.println("p2 apres rotation de centre O et d'angle " + angle + " : " + p2);

        System.out.println(p1.equals(p2));
        System.out.println(p2.equals(p1));
    }
}