Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package librojava;
- /**
- *
- * @author profe
- */
- public class Pir {
- /**
- * Este método construye una pirámide con el pico apuntando hacia arriba
- * @param caracter es el carácter con el que se dibujará la pirámide
- * @param base describe la longitud de la base
- * @return
- */
- public static char Arriba(char caracter, int base) {
- for (int x = base; x >= 1; x--) {
- int a = base;
- boolean controller = true;
- while (controller) {
- System.out.print(" ");
- if (a + x == base) {
- controller = false;
- } else {
- controller = true;
- a--;
- }
- }
- int b = base;
- System.out.print(caracter);
- controller = true;
- while (controller) {
- if (x != base) {
- System.out.print(" " + caracter);
- }
- if (b - x == 1) {
- controller = false;
- } else {
- controller = true;
- b--;
- }
- }
- System.out.println("");
- }
- return caracter;
- }
- /**
- * Este método construye una pirámide con el pico apuntando hacia abajo
- * @param caracter es el carácter con el que se dibujará la pirámide
- * @param base describe la longitud de la base
- * @return
- */
- public static char Abajo(char caracter, int base) {
- for (int x = base; x >= 1; x--) {
- int a = base;
- boolean controller = true;
- while (controller) {
- System.out.print(" ");
- if (a - x == 0) {
- controller = false;
- } else {
- controller = true;
- a--;
- }
- }
- System.out.print(caracter);
- for (int y = x; y > 1; y--) {
- System.out.print(" " + caracter);
- }
- System.out.println("");
- }
- return caracter;
- }
- public static char Izquierda(char caracter, int base) {
- String build;
- build = Character.toString(caracter);
- return caracter;
- }
- public static char Derecha(char caracter, int base) {
- String build;
- build = Character.toString(caracter);
- return caracter;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement