Advertisement
_Zume

Untitled

Apr 24th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1.  
  2. public class Ejecutador {
  3.  
  4.     public static void main(String[] args) {
  5.         DrawMeACircle(3, 3, 3, "*"); // should print to the screen an ellipse looking circle
  6.     }
  7.  
  8.     public static void DrawMeACircle(double posX, double posY, double radius, String patron) {
  9.  
  10.         double xaxis = 20;  // escanear coordenadas
  11.         double yaxis = 20;  // " "
  12.  
  13.         for (double x = 0; x < xaxis; x++) {
  14.             for (double y = 0; y < yaxis; y++) {
  15.  
  16.                 // obtencion de coordenadas
  17.                 double a = Math.abs((posX - x) * (posX - x));
  18.                 double b = Math.abs((posY - y) * (posY - y));
  19.  
  20.                 double c = Math.abs(a + b);        
  21.                 double d = Math.abs(radius * radius);
  22.  
  23.                 double arbitraryNumber = 2;
  24.                 if (Math.abs(c - d) < arbitraryNumber) {
  25.  
  26.                   System.out.print(patron);
  27.                 }
  28.                 else {
  29.                     System.out.print(' ');
  30.                 }
  31.             }  
  32.             System.out.println();
  33.         }
  34.     }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement