Пример #1
0
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.println("Enter the sides of Triangle: ");
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double c = sc.nextDouble();

    Triangle tri1 = new Triangle(a, b, c);
    double res = tri1.area();
    if (a + b > c && b + c > a && c + a > b) {
      System.out.println("The area of triangle is: " + res);
    } else {
      System.out.println("This is not Triangle!");
    }

    System.out.println("Enter the sides of another Triangle: ");
    double e = sc.nextDouble();
    double f = sc.nextDouble();
    double g = sc.nextDouble();
    Triangle tri2 = new Triangle(e, f, g);
    res = tri2.area();
    if (a + b > c && b + c > a && c + a > b) {
      System.out.println("The area of another triangle is: " + res);
    } else {
      System.out.println("This is not Triangle!");
    }
    sc.close();
  }
Пример #2
0
 public static void main(String[] args) {
   Triangle t = new Triangle(new Point(1, 2), new Point(3, 4), new Point(1, 3));
   t.printPoints();
   System.out.printf("Umfang: %f\nFläche %f\nBewege um (2|4) ...\n", t.perimeter(), t.area());
   t.move(2, 4);
   t.printPoints();
 }
Пример #3
0
  public static void main(String[] args) {
    // Figure f = new Figure(10, 10);
    Rectangle r = new Rectangle(9, 5);
    Triangle t = new Triangle(10, 8);

    System.out.println("Pole: " + r.area());
    System.out.println("Pole: " + t.area());
  }