Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Circle.class
Binary file not shown.
23 changes: 23 additions & 0 deletions Circle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import java.lang.Math;

public class Circle {
double a;
public Circle(double radius) {
if (radius <= 0) {throw new RuntimeException("Radius cannot be smaller than 0");}
a = radius;
}

public double area() {
return Math.round(3.14 * a * a);
}

public double circumference() {
return Math.round(2 * 3.14 * a);
}

public String toString() {
return "Circle with radius of " + a + " has the area of "
+ area() + " and the circumference of " + circumference() + " units.";
}

}
Binary file added Proov1.class
Binary file not shown.
20 changes: 0 additions & 20 deletions Ristkylik.java

This file was deleted.

Binary file added circleTest.class
Binary file not shown.
12 changes: 12 additions & 0 deletions circleTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class circleTest {
public static void main(String[] args) {
Circle table1 = new Circle(145);
Circle wheel = new Circle(40);
Circle glass = new Circle(2.4);
System.out.println(table1.area() + " " + table1.circumference());
System.out.println(wheel.area());
System.out.println(glass.area());
System.out.println(table1);
System.out.println(wheel.toString());
}
}