public class Triangle {
private static AtomicInteger count = new AtomicInteger(0);
private int a;
private int b;
private int c;
Triangle(int a, int b, int c) {
if (count.intValue() >= 10) {
throw new RuntimeException("创建对象数量超过10个");
}
if (a + b < c || a + c < b || b + c < a) {
throw new RuntimeException("参数不符合三角形约束条件");
}
this.a = a;
this.b = b;
this.c = c;
count.incrementAndGet();
}
}