Open avielcx opened 1 year ago
Did you update the Circle and Rectangle classes? The code for the two classes in coursemology are not by default the code provided for them in the question.
@irving11119 yea, I copied and pasted from the notes. It passed the verify test case and failed the other.
I think I have the same problem where it is failing the Main.main(args), but passing the Main.main(args)(Verify)
Is it possible to send the code here as some of us did not encounter this issue, and thus difficult to debug
public class Main { //TODO add your methods here
private static Shape[] shapes = new Shape[100];
private static int shapeCount = 0;
public static void addShape(Shape s){
shapes[shapeCount] = s;
shapeCount++;
}
public static void printAreas() {
for (int i = 0; i < shapeCount; i++) {
System.out.println(shapes[i].area() + "\n");
}
}
public static void main(String[] args) {
addShape(new Circle(5));
addShape(new Rectangle(3, 4));
addShape(new Circle(10));
printAreas();
addShape(new Rectangle(4, 4));
printAreas();
}
}
Try removing additional \n in the println in printArea?
Off topic but @tangphi FYI you can format code using code fences ```
like this
```java
public class Main {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
```
giving the output
public class Main {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
Thanks deleting the \n worked!
Hi Prof
I have the same output as the sample test case on my terminal but it stills shows wrong answer on coursemology. Appreciate your help.