الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

برنامجي ماطلع لي اوت بوت مضبووط ولا ادري وين الغلط ؟؟؟

بدأه miss totah في 30 أبريل 2009 · 2 رد · 587 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكــم ورحمـة الله وبركاتــه ،،

هذا السؤال وحلي

مادري وين غلطي فيه ؟؟؟؟؟؟؟؟

.

Þ Define class called Draw_Shape which has the following:

One data member ch.

Set member function for the data member which read the value from the user.

Get member function that returns the value of the data member.

Constructor function that initializes the data member with initial value ch=' '.

Validate() member function that validate if value of the ch is *, #, %, &, @ or $, if not prompt the user to reenter it again.

Draw_Diamond () member function that use output statements which print either a character or a single blank. You should maximize your use of repetition and minimize the number of output statements.

Draw_ Blank_ Square() member function that draws blank square shape of symbols based on ch and it is 7X7 square.

Þ Define global function Menu that print choices (i.e.1. Draw diamond, 2. Draw blank square, 3. Exit). These choices must be repeated until the user selects exit. This function should call the corresponding calculating function based on the user's choice.

Þ Declare an object of type Draw_Shape and test your class.

Þ The program should contains Two files

§ Header file:- which contain declaration of private (data members) and public (member functions) with its definitions.

§ Source File: - which contain the main function.

[gcode=cpp]

#include<iostream.h>

class drawShape{

char ch ;

public:

void setch()

{

cout<<"enter the character";

cin>>ch;

}

char getch()

{

return ch ;

}

drawShape()

{

ch=' ';

}

void validate()

{

setch();

if(ch !='#'||'$'||'%'||'*'||'&'||'@')

cout<<"Enter the correct character";

cin>>ch;

}

void draw_Daimond(){

int size;

cout<<"Enter the size";

cin>>size;

for(int row=1;row<=size;++row){

for(int space=1;space<=size;++space)

cout<<' ';

for (int i=0;i<=2*(row-1);i++)

cout<<ch;

cout<<endl;

}

for (int row=(size-1);row>=1;row--)

{

for(int space=1;space<=size-row;space++)

cout<<' ';

for(int i=0;i<=2*(row-1);i++)

cout<<ch;

cout<<endl;

}}

void draw_square(){

int side, rowPosition, size;

cout << "Enter the square side: ";

cin >> side;

size = side;

while ( side > 0 ) {

rowPosition = size;

while ( rowPosition > 0 ) {

if ( size == side || side == 1 || rowPosition == 1 ||

rowPosition == size )

cout << ch;

else

cout << ' ';

--rowPosition;

}

cout << '\n';

--side;

}

cout << endl;

}

};

int main (){

drawShape ds;

int choice;

{cout<<"_____MENU>>>\n";

cout<<"1:draw Daimond\n";

cout<<"2 : draw square\n";

cout<<"3 : exist\n";

cout<<"ENTER YOUR CHOICE";

cin>>choice;

while(choice!=3)

{

if(choice==1)

{

ds.setch();

ds.validate();

ds.getch();

ds.draw_Daimond();

}

if(choice==2)

{

ds.setch();

ds.validate();

ds.getch();

ds.draw_square();

}

cout<<"_____MENU>>>\n";

cout<<"1:draw Daimond\n";

cout<<"2 : draw square\n";

cout<<"3 : exist\n";

cout<<"ENTER YOUR CHOICE";

cin>>choice;

}

cout<<"Exist";

return 0 ;

}}[/gcode ]

ماعرفت احط الكود بالشكل المناسب)(

تم تعديل هذه المشاركة بواسطة miss totah في 30 أبريل 2009 في 15:56

#2

السلام عليكــم ورحمـة الله وبركاتــه

،،

تفضلى أختنا الكريمه


class drawShape{
char ch;
public:
void setch()
{
cout<<"enter the character";
cin>>ch;
}
char getch()
{
return ch;
}
drawShape()
{
ch=' ';
}
void validate()
{
while(ch !='#' && ch !='$' && ch !='%' && ch !='*' && ch !='&' && ch !='@')
{
cout<<"Enter the correct character";
cin>>ch;
}
}
void draw_Daimond(){
int size;
cout<<"Enter the size";
cin>>size;
for(int row=1;row<=size;++row){
for(int space=1;space<=size-row;++space)
cout<<' ';
for (int i=0;i<=2*(row-1);i++)
cout<<ch;
cout<<endl;
}
for ( row=(size-1);row>=1;row--)
{
for(int space=1;space<=size-row;space++)
cout<<' ';
for(int i=0;i<=2*(row-1);i++)
cout<<ch;
cout<<endl;
}}
void draw_square(){
int side, rowPosition, size;
cout << "Enter the square side: ";
cin >> side;
size = side;
while ( side > 0 ) {
rowPosition = size;
while ( rowPosition > 0 ) {
if ( size == side || side == 1 || rowPosition == 1 ||
rowPosition == size )
cout << ch;
else
cout << ' ';
--rowPosition;

}
cout << '\n';
--side;
}
cout << endl;
}
};
int main (){
drawShape ds;
int choice;
cout<<"_____MENU>>>\n";
cout<<"1:draw Daimond\n";
cout<<"2 : draw square\n";
cout<<"3 : exist\n";
cout<<"ENTER YOUR CHOICE";
cin>>choice;
while(choice!=3)
{
if(choice==1)
{
ds.setch();
ds.validate();
ds.getch();
ds.draw_Daimond();
}
if(choice==2)
{
ds.setch();
ds.validate();
ds.getch();
ds.draw_square();
}
cout<<"_____MENU>>>\n";
cout<<"1:draw Daimond\n";
cout<<"2 : draw square\n";
cout<<"3 : exist\n";
cout<<"ENTER YOUR CHOICE";
cin>>choice;
}
cout<<"Exist";
return 0;
}
#include<iostream.h>

اللهم صل على سيدنا محمد وعلى آله وصحبه وسلم

#3

جزيت خيرا

اخي الكريم

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…