Write a PL/SQL program to draw Charminar. - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Thursday, October 5, 2017

Write a PL/SQL program to draw Charminar.

PL/SQL program to draw Charminar.

Program:

DECLARE

given_front_space NUMBER := 50;
given_space_btn_minars NUMBER := 150;
total_building_width NUMBER := 150 + 9+9; -- calc the total width, middle space and the both the dome with with the wall star

space_btn_front_dome1 NUMBER;
space_btn_front_dome2 NUMBER;




/* ####################### Procedure to get the cursor down by certain lines ##################*/
PROCEDURE print_blank_lines(no_of_blank_lines NUMBER)
IS
BEGIN
FOR blank_lines IN 1 .. no_of_blank_lines
LOOP
DBMS_OUTPUT.NEW_LINE;
END LOOP;
END;

/* ####################### END OF Procedure to get the cursor down by certain lines ##################*/





/* #################### Procedure to print space ############################*/
PROCEDURE print_space(len_of_space NUMBER)
IS
BEGIN
FOR amt_of_space IN 1 .. len_of_space
LOOP
DBMS_OUTPUT.PUT(' ');
END LOOP;
END;

/* #################### Procedure to print only one star ############################*/





/* ################ Procedure to print a 2 star and a 1 space ################################*/
PROCEDURE two_star_and_1space(space_btn_stars NUMBER)
IS
BEGIN
DBMS_OUTPUT.PUT('*');
print_space(space_btn_stars);
DBMS_OUTPUT.PUT('*');

END;

/* ################ Procedure to print a star and a space ################################*/



/*################## Procedure to print ! #################################################*/
PROCEDURE single_special(no_of_single NUMBER)
IS
BEGIN
FOR single_char in 1 .. no_of_single
LOOP
DBMS_OUTPUT.PUT('!');
END LOOP;
END;

/*################## end of Procedure to print ! #################################################*/


/*################## Procedure to print * #################################################*/
PROCEDURE single_star(no_of_star NUMBER)
IS
BEGIN
FOR single_char in 1 .. no_of_star
LOOP
DBMS_OUTPUT.PUT('*');
END LOOP;
END;

/*################## end of Procedure to print ! #################################################*/






/* ################### Procedure to print single ~ #########################################*/
PROCEDURE single_tilda(no_of_tilda NUMBER)
IS
BEGIN
FOR single_tilda_loop in 1 .. no_of_tilda
LOOP
DBMS_OUTPUT.PUT('~');
END LOOP;
END;
/* ################### end of Procedure to print single ~ #########################################*/


/* ################## Procedure to print hash # ################################################# */
PROCEDURE single_hash(no_of_hash NUMBER)
IS
BEGIN
FOR single_hash_loop in 1 .. no_of_hash
LOOP
DBMS_OUTPUT.PUT('#');
END LOOP;
END;

/* ################## end of Procedure to print hash # ################################################# */



/* ###########################PROCEDURE to pring percent % #############################################*/
PROCEDURE single_percent(no_of_percent NUMBER)
IS
BEGIN
FOR single_percent_loop in 1 .. no_of_percent
LOOP
DBMS_OUTPUT.PUT('%');
END LOOP;
END;


/* ########################### end of PROCEDURE to pring percent % #########################################*/




/* ###########################PROCEDURE to pring line | #############################################*/
PROCEDURE single_line(no_of_line NUMBER)
IS
BEGIN
FOR single_percent_loop in 1 .. no_of_line
LOOP
DBMS_OUTPUT.PUT('|');
END LOOP;
END;


/* ###########################end of PROCEDURE to pring line | #############################################*/




/* #################### Procedure to print ~! in a set ##################################*/
PROCEDURE special_char_verti(no_of_special NUMBER)
IS
BEGIN
FOR special_char in 1 .. no_of_special
LOOP
DBMS_OUTPUT.PUT('~!');
END LOOP;
END;
/* #################### end of Procedure to print !~ in a set ##################################*/





--- ~~~~~~~ printing begins from here ~~~~~~~~~~~-----





/* ################Procedure to print the pines of Charminar #################################*/
PROCEDURE front_pines
IS

BEGIN

-- print the 1st and 2nd pine tips
print_space(given_front_space); -- print the space in front of the tip of the pine
two_star_and_1space(given_space_btn_minars); -- prints the tip of the two front pines
dbms_output.new_line;


-- reduce the front space and the middle space by 1 and 2 to get the slant look of the pine
given_front_space := given_front_space - 1;
given_space_btn_minars := given_space_btn_minars - 2;


FOR tip_of_loop in 1 .. 2
LOOP
-- prints the 1st pine in the front two pines
print_space(given_front_space);
two_star_and_1space(1);

-- prints the 2nd pine in the front two pines
print_space(given_space_btn_minars);
two_star_and_1space(1);

dbms_output.new_line;
END LOOP;

END;


/* ################End of Procedure to print the pines of Charminar #################################*/








/*############### Procedure to print the two domes in the front two minars ########################*/
PROCEDURE front_domes
IS
BEGIN

-- first front dome
given_front_space := given_front_space - 2; -- remove 2,coz bulge from pine to dome
space_btn_front_dome1 := 2 + 3 + 2; --ie space reduced frm front space, pines two stars and one space,
-- and 4 space before the last star


-- print first dome with the front space
print_space(given_front_space);
two_star_and_1space(space_btn_front_dome1);





-- second front dome
given_space_btn_minars := given_space_btn_minars - space_btn_front_dome1; -- remove the btn_dome1,coz
-- the center space starts from the middle and so consider the middle space 3 + two 2 sides
space_btn_front_dome2 := 2 + 3 + 2;

-- print the second dome with the front space

print_space( given_space_btn_minars);
two_star_and_1space(space_btn_front_dome2);


dbms_output.new_line;




-- first front dome for slant look
given_front_space := given_front_space - 2;
space_btn_front_dome1 := space_btn_front_dome1 + 2 + 2;

-- second front dome for slant look
given_space_btn_minars := given_space_btn_minars - 4 ; -- remove only 4 coz, dont have to consider the center space
-- coz, the center space is already removed from the first star of the dome
space_btn_front_dome2 := space_btn_front_dome2 + 2 + 2; -- space_btn_front_dome1 = space_btn_front_dome2


FOR top_domes in 1 .. 2
LOOP

-- print first dome with the front space
print_space(given_front_space);
two_star_and_1space(space_btn_front_dome1);



-- print the second dome with the front space

print_space( given_space_btn_minars);
two_star_and_1space(space_btn_front_dome2);

dbms_output.new_line;




END LOOP;
END;
/*############### END of Procedure to print the two domes in the front two minars ########################*/



/* ###################### Procedure to print the first horizontal line in front minars ################# */
PROCEDURE first_hori_frnt_minar(p_front_space NUMBER,p_space_btn_front_dome NUMBER,p_space_btn_minars NUMBER)
IS
BEGIN

-- to print the 1st vertical bar in the 1st front minar
print_space(p_front_space);
single_special(1);

special_char_verti(p_space_btn_front_dome/3);


-- to print the 1st vertical bar in the 2nd front minar
print_space(p_space_btn_minars);
single_special(1);

special_char_verti(p_space_btn_front_dome/3);

dbms_output.new_line;
END;
/* ###################### end of Procedure to print the first vertical line in front minars #################*/




/* ################# Procedure to print the top poles of hte front minars ######################## */
PROCEDURE top_pole_frnt_minars(p_front_space NUMBER,p_space_btn_front_dome NUMBER,p_space_btn_minars NUMBER, len_of_pillar NUMBER)
IS
BEGIN

FOR pillar_len in 1 .. len_of_pillar
LOOP
-- print the front space, before printing the minar
print_space(p_front_space);
two_star_and_1space(p_space_btn_front_dome);

-- print the middle space, before printing the 2nd minar
print_space(p_space_btn_minars);
two_star_and_1space(p_space_btn_front_dome);

dbms_output.new_line;

END LOOP;
END;

/* ################# END OF Procedure to print the top poles of hte front minars ######################## */


/* ################Procedure to print the second horizontal line in the front minars ###################### */

PROCEDURE second_hori_frnt_minar
IS
snd_vert_frnt_space NUMBER := given_front_space ;
verti_lent NUMBER := space_btn_front_dome1;
snd_verti_btn_minar NUMBER := given_space_btn_minars ;

BEGIN
-- prints the vertical line in the first minar
print_space(snd_vert_frnt_space - 2);
single_special(verti_lent+ 7);

-- prints the vertical line in the second minar
print_space(snd_verti_btn_minar - 4);
single_special(verti_lent+ 7);
DBMS_OUTPUT.NEW_LINE;

END;

/* ################END OF Procedure to print the second vertical line in the front minars ###################### */



/* ############### PROCEDURE to print the bottom part of front minar, with behind minars ################### */
PROCEDURE front_down_hind_top
IS
fbhu_front_space NUMBER := given_front_space;
fbhu_dome_space NUMBER := space_btn_front_dome1;
fbhu_middle_Sminar NUMBER := given_space_btn_minars/2;
fbhu_Sminar_frontSpace NUMBER := given_space_btn_minars/4 ;
fbhu_Sminar_backSpace NUMBER := given_space_btn_minars/4 - 4; -- -4 for cosmetic purpose
fbhu_space_btn_Sminar NUMBER := 4;


-- print the first BIG minar
PROCEDURE top4_big_minar1
IS
BEGIN

print_space(fbhu_front_space); -- front space of the the bottom minar
two_star_and_1space(fbhu_dome_space); -- prints the stars with the dome space in btn
END;


-- print the last BIG minar
PROCEDURE top4_big_minar2
IS
BEGIN


print_space( fbhu_Sminar_backSpace - 3); -- front space of the the bottom minar,-3 for cosmetic purpose
two_star_and_1space(fbhu_dome_space); -- prints the stars with the dome space in btn
END;



-- prints the 1st small minar
PROCEDURE top4_small_minar1
IS
BEGIN
print_space(fbhu_Sminar_frontSpace -2);
two_star_and_1space(fbhu_space_btn_Sminar);
END;


-- prints the 2nd small minar
PROCEDURE top4_small_minar2
IS
BEGIN
print_space(fbhu_middle_Sminar - 4);
two_star_and_1space(fbhu_space_btn_Sminar);
END;



PROCEDURE build_verti_4pillars
IS
BEGIN
-- BUILD THE PILLARS OF ALL THE 4 MINARS
FOR top_four_minars in 1 .. 2
LOOP
top4_big_minar1;
top4_small_minar1;

top4_small_minar2;
top4_big_minar2;

DBMS_OUTPUT.NEW_LINE;


END LOOP;
END;



BEGIN

top4_big_minar1; -- prints the first big minar

-- prints the first SMALL minar pine
print_space(fbhu_Sminar_frontSpace);
DBMS_OUTPUT.PUT('^');


-- prints the second SMALL minar pine
print_space(fbhu_middle_Sminar);
DBMS_OUTPUT.PUT('^');


-- print the last BIG minar
print_space(fbhu_Sminar_backSpace); -- front space of the the bottom minar
two_star_and_1space(fbhu_dome_space); -- prints the stars with the dome space in btn -- pritn the last big minar


DBMS_OUTPUT.NEW_LINE;


-- BUILD THE PILLARS OF ALL THE 4 MINARS

build_verti_4pillars;



-- BUILD HIND MINAR VERTICAL DESIGN WITH TILDA

top4_big_minar1; -- prints the first

print_space(fbhu_Sminar_frontSpace -2);
single_tilda(3); -- prints the vertical line in the first small minar

print_space(fbhu_middle_Sminar - 4);
single_tilda(3); -- prints the vetical line in the second small minar

-- print the last BIG minar
print_space( fbhu_Sminar_backSpace - 4); -- front space of the the bottom minar,-3 for cosmetic purpose
two_star_and_1space(fbhu_dome_space); -- prints the stars with the dome space in btn

dbms_output.new_line;

-- Prints the bottom of the

build_verti_4pillars;

-- BUILD THE LAST HORIZONTAL LINE OF THE MINARS

-- 1 big pillar hash
print_space(fbhu_front_space-1); -- front space of the the bottom minar
single_hash(7);

-- 1 small pillar hash
print_space(fbhu_Sminar_frontSpace - 4);
single_hash(3);

-- 2 small pillar hash

print_space(fbhu_middle_Sminar - 4);
single_hash(3);
-- 2 big pillar hash

print_space(fbhu_Sminar_backSpace - 4); -- front space of the the bottom minar
single_hash(7);


dbms_output.new_line;




END;

/* ############### END OF PROCEDURE to print the bottom part of front minar, with behind minars ################### */



/* ################ PROCEDURE to print the top desing of the building ####################################### */
PROCEDURE curve_top_building
IS
BEGIN
-- top CURVE desing of the building
print_space(given_front_space);
single_tilda(72);
dbms_output.new_line;

END;

/* ################ end of PROCEDURE to print the top desing of the building ####################################### */





/* ################ Procedure to print the top most desing after the curve #################################*/
PROCEDURE top_building_design
IS
BEGIN
FOR top_desing_loop in 1 .. 4
LOOP

print_space(given_front_space);
single_percent(63);
dbms_output.new_line;
END LOOP;
END;

/* ################ END OF Procedure to print the top most desing after the curve ############################*/





/* ############### Procedure to print the bottom pillar in the building ############################## */
PROCEDURE middle_building_design
IS
mid_build_toggle NUMBER;
mid_build_sp2 NUMBER := 14; -- total_middle ie 150/2 = around 72/4 - 4 for !!!
print_clock VARCHAR2(1) := 'Y';

PROCEDURE linePillar_space
IS
BEGIN
-- prints the first | lines in the middle building design
print_space(given_front_space);
single_line(space_btn_front_dome1 * 2);

--print the middle space between the two | design pillars in the building

print_space(given_space_btn_minars);
single_line(space_btn_front_dome1 * 2);

dbms_output.new_line;
END;



PROCEDURE clock_window
IS
BEGIN
-- prints the first | lines in the middle building design
print_space(given_front_space);
single_line(space_btn_front_dome1 * 2);

-- print the first top part of the window
FOR top_window in 1 .. 3
LOOP
print_space(mid_build_sp2);
single_special(4);
END LOOP;

-- print the clock
IF print_clock = 'Y'
THEN
print_space(mid_build_sp2);
DBMS_OUTPUT.PUT('@');
mid_build_toggle := mid_build_sp2 ;
ELSIF print_clock = 'N'
THEN
mid_build_toggle := (mid_build_sp2 * 2) + 4; -- *2 coz, the space before and after clock along with the 3 space occupied by the
-- the clock, this is when the clock is not printed

END IF;

-- this prints the clock or no clock space
print_space(mid_build_toggle);
single_special(4);



-- print the second top part of the window
FOR top_window in 1 .. 2
LOOP
print_space(mid_build_sp2);
single_special(4);
END LOOP;

-- print the second | line in the middle building design
print_space(mid_build_sp2 - 3); -- -3 for cosmetic purpose
single_line(space_btn_front_dome1 * 2);

dbms_output.new_line;

END;

BEGIN

linePillar_space; -- prints the middle part of the building with lines and spaces

-- PRINTS THE MIDDLE DESIGN WITH THE WINDOWS AND THE CENTER CLOCK
clock_window;

print_clock := 'N';
clock_window;
END;
/* ############### end of Procedure to print the bottom pillar in the building ###################### */
/* ################ Procedure to print the 2nd middle part of the building ###########################*/
PROCEDURE mid_in_minar
IS
BEGIN
FOR middle_space in 1 .. 3
LOOP
-- prints the 1st pine in the front two pines
print_space(given_front_space);
two_star_and_1space(space_btn_front_dome1);
-- prints the 2nd pine in the front two pines
print_space(given_space_btn_minars + 2);
two_star_and_1space(space_btn_front_dome2);
dbms_output.new_line;
END LOOP;
END;
/* ################ end of Procedure to print the 2nd middle part of the building ###########################*/
/* ########### Procedure to print the bottom of the building with the door ####################### */
PROCEDURE bottom_door
IS
space_before_door NUMBER := (given_space_btn_minars/2);
space_after_door NUMBER:= given_space_btn_minars - space_before_door;
door_middle_space NUMBER :=0;
door_top VARCHAR2(1) := 'Y';
len_of_side_doors NUMBER := 5;

PROCEDURE enterence_door
IS
BEGIN
FOR door_bend in 1 .. len_of_side_doors
LOOP

IF door_top = 'Y'
THEN
space_before_door := space_before_door - 7;
door_middle_space := door_middle_space + 7 + 7 + 1;
space_after_door := space_after_door - 8.1;
END IF;

-- prints the first bottom minar
print_space(given_front_space);
two_star_and_1space(space_btn_front_dome1);

-- prints the left side of the door
print_space(space_before_door);
single_star(1);

-- print the right side of the door
print_space(door_middle_space);
single_star(1);

-- print the last bottom minar
print_space(space_after_door);
two_star_and_1space(space_btn_front_dome1);
dbms_output.new_line;
END LOOP;
END;
BEGIN

-- prints the first bottom minar

print_space(given_front_space);
two_star_and_1space(space_btn_front_dome1);

-- print the starting of the door
print_space(space_before_door);
single_star(1);

-- print the second bottom minar

print_space(space_after_door);
two_star_and_1space(space_btn_front_dome1);
dbms_output.new_line;

enterence_door; -- to print the top part of the door
door_top := 'N'; -- this is stop reducin the space values in front and behind the door
len_of_side_doors := 11; -- inc's the length of the door after the bend

space_before_door := space_before_door - 2;
door_middle_space := door_middle_space + 4;
space_after_door := space_after_door - 2;
enterence_door;
END;

/* ########### end of Procedure to print the bottom of the building with the door ####################### */
BEGIN

-- get the cursor down by some lines

print_blank_lines(5);


-- Two pines of the front 2 minars

front_pines;
front_domes;
first_hori_frnt_minar(given_front_space,space_btn_front_dome1,given_space_btn_minars-1); -- -1 just for cosmetic purpose

top_pole_frnt_minars(given_front_space,space_btn_front_dome1,given_space_btn_minars, 3);

second_hori_frnt_minar;
front_down_hind_top;

-- building design
top_building_design;
middle_building_design;
curve_top_building;

mid_in_minar;
bottom_door;
-- curve_top_building;

END;

No comments:

Post a Comment