Java Shapes Project
Hi! I'm learning Java and I've been sitting on the Shapes project in Java for several hours now. I pass all the test cases, beside #3, which is hidden. I thought that it was because of integer overflow, but even after dealing with it, it wouldn't pass. I'm adding my code below, and if someone could help me out I'd really appreciate it. Thanks! --------------------------- abstract class Shape { int width; abstract void area(); Shape (int width){ this.width = width; } } //your code goes here class Square extends Shape { Square(int x){ super(x); } @Override public void area(){ int calcArea = this.width * this.width; if (calcArea >= 0){ System.out.println(calcArea); } else { System.out.println(Integer.MAX_VALUE * Integer.MAX_VALUE); } } } class Circle extends Shape { Circle(int y){ super(y); } public void area(){ int calcArea = this.width * this.width; double circleArea = calcArea * Math.PI; if (calcArea >= 0){ System.out.println(circleArea); } else { System.out.println(Integer.MAX_VALUE * Integer.MAX_VALUE * Math.PI); } } } public class Program { public static void main(String[ ] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); Square a = new Square(x); Circle b = new Circle(y); a.area(); b.area(); } }