Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. package cz.muni.fi.pb162.project.geometry;
  2.  
  3.  
  4. /**
  5.  * Write a description of class GeneralRegularPolygon here.
  6.  *
  7.  * @author Filip Prazak
  8.  * @version 23.10.2014
  9.  */
  10. public class GeneralRegularPolygon implements RegularPolygon, Colored{
  11.     public Vertex2D stred;
  12.     private double delkaHrany;
  13.     private int pocetHran;
  14.     private String color = "black";
  15.    
  16.    
  17.     GeneralRegularPolygon(Vertex2D stred, int delkaHrany, int pocetHran){
  18.         this.stred = stred;
  19.         this.delkaHrany = delkaHrany;
  20.         this.pocetHran = pocetHran;      
  21.     }
  22.    
  23.     public double getRadius{
  24.         return pocetHran/(2*Math.sin(Math.PI/pocetHran);
  25.     }
  26.    
  27.     public double getArea{
  28.         return 1/2*pocetHran*getRadius()*getRadius()*Math.sin(2*Math.PI/pocetHran); //blbost
  29.     }
  30.    
  31.     public String toString(){
  32.         return pocetHran +"-gon:center=["+stred+"], edge length="+delkaHrany+", color="+color;
  33.     }
  34.    
  35. {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement