Exemplo n.º 1
0
  public static void main(String[] args) {

    Octagon tijelo = new Octagon(5);
    Octagon tijelo2 = new Octagon(7);

    if (tijelo instanceof Cloneable) {
      try {
        tijelo2 = (Octagon) tijelo.clone();
      } catch (CloneNotSupportedException e) {
        e.printStackTrace();
      }
    }

    System.out.println("Compare: " + tijelo.compareTo(tijelo2));
  }
Exemplo n.º 2
0
  public void draw() {
    background(255);
    translate(width / 2, height / 2);

    stroke(0);
    fill(255, 255, 0);

    h.render();

    println("Info for the Octagon.");
    println("-----------------------------");
    println("Area:           " + h.area());
    println("Perimeter:      " + h.perimeter());
    println("Internal Angle: " + h.internalAngle());
    println("External Angle: " + h.externalAngle());
  }
Exemplo n.º 3
0
 @Override
 public int compareTo(Octagon o) {
   if (getArea() > o.getArea()) return 1;
   else if (getArea() < o.getArea()) return -1;
   else return 0;
 }