package cn.edu.bjut.chapter4_1; public class Triangle extends Shape { private double a, b, c; public Triangle(double a, double b, double c) { this.a = a; this.b = b; this.c = c; } @Override public double area() { double p = (a + b + c) / 2; return Math.sqrt(p * (p - a) * (p - b) * (p - c)); } @Override public double perimeter() { return (a + b + c); } }