Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Ejecutador {
- public static void main(String[] args) {
- DrawMeACircle(3, 3, 3, "*"); // should print to the screen an ellipse looking circle
- }
- public static void DrawMeACircle(double posX, double posY, double radius, String patron) {
- double xaxis = 20; // escanear coordenadas
- double yaxis = 20; // " "
- for (double x = 0; x < xaxis; x++) {
- for (double y = 0; y < yaxis; y++) {
- // obtencion de coordenadas
- double a = Math.abs((posX - x) * (posX - x));
- double b = Math.abs((posY - y) * (posY - y));
- double c = Math.abs(a + b);
- double d = Math.abs(radius * radius);
- double arbitraryNumber = 2;
- if (Math.abs(c - d) < arbitraryNumber) {
- System.out.print(patron);
- }
- else {
- System.out.print(' ');
- }
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement