# Lab2 Answer

{% code title="GravityCalculator.java" %}

```java
public class GravityCalculator {
    double g = 9.8;
    
    public double freeFallSpeed(double t) {
        return g*t;
    }
    
    public double freeFallDistance(double t) {
        return 0.5*g*t*t;
    }
}
```

{% endcode %}

{% code title="RegularPolygon.java" %}

```java
public class RegularPolygon {
    public double side_length;
    public int sides;
    
    public RegularPolygon(double x) {
        side_length = x;
        sides = 4;
    }  
    public RegularPolygon(double x, int y) { //constructor overloading
        side_length = x;
        sides = y;
    }
    
    public double getPerimeter() {
        return side_length * sides;
    }
    public double getArea() {
        return (double)1/4 * sides * side_length * side_length / Math.tan(3.14/sides);
    }
}
```

{% endcode %}

{% code title="" %}

```java
public class Main
{
    public static void main(String[] args) {
        GravityCalculator cal = new GravityCalculator();
        double t1 = 5.0;
        double t2 = 8.5;
        double t3 = 15;
        System.out.println(cal.freeFallDistance(t1));
        System.out.println(cal.freeFallDistance(t2));
        System.out.println(cal.freeFallDistance(t3));
        
        RegularPolygon p1= new RegularPolygon(4.5, 4);
        RegularPolygon p2= new RegularPolygon(5.0, 6);
        RegularPolygon p3= new RegularPolygon(2, 3);
        System.out.println(p1.getArea());
        System.out.println(p1.getPerimeter());
        
        System.out.println(p2.getArea());
        System.out.println(p2.getPerimeter());	
        
        System.out.println(p3.getArea());
        System.out.println(p3.getPerimeter());
	}
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://scls-cs.gitbook.io/scls-apcs-lab/methods/in-class-test/lab2-answer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
