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

الاعضاء الكرام ، هادا كود برنامج كاتبه بstruct ممكن حد يحوله لclass

بدأه احمد رشوان في 13 يونيو 2008 · 4 رد · 697 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

هادا برنامج لشركة سيارات كتبه بستراكت ممكن حدا يحوله لكلاس

#include <iostream.h>

#include <process.h>

#include <fstream.h>

fstream stfile;

struct car

**

int num,volume,engine;

char color[10];

char model[10],name[10],address[10];

long cost,no,code;

};

int i=-1,s;

car st [10];

void insert (car []);

void sale (car []);

void searching (car []);

void deleting (car []);

void display (car []);

void search (car[]);

void main ()

**

int n;

do

**

system("cls");

cout<<endl;

cout<<endl;

cout<<"\t\t_______________________________________ __________"<<endl;

cout<<"\t\t*\t\t\t\t\t\t*\n";

cout<<"\t\t*\t\t\t\t\t\t*\n";

cout<<"\t\t*\t\t\t\t\t\t*\n";

cout<<"\t\t*\t1.inserting : \t\t\t\t*\n\t\t*";

cout<<"\t\t\t\t\t\t*\n";

cout<<"\t\t*\t2.Sale : \t\t\t\t*\n\t\t*";

cout<<"\t\t\t\t\t\t*\n";

cout<<"\t\t*\t3.searching : \t\t\t\t*\n\t\t*";

cout<<"\t\t\t\t\t\t*\n";

cout<<"\t\t*\t4.deleting : \t\t\t\t*\n\t\t*";

cout<<"\t\t\t\t\t\t*\n";

cout<<"\t\t*\t5.display : \t\t\t\t*\n\t\t*";

cout<<"\t\t\t\t\t\t*\n";

cout<<"\t\t*\t6.search the car sale : \t\t*\n\t\t*";

cout<<"\t\t\t\t\t\t*\n";

cout<<"\t\t*\t7.exit : \t\t\t\t*\n\t\t*";

cout<<"\t\t\t\t\t\t*\n";

cout<<"\t\t*\t\t\t\t\t\t*\n\t\t*";

cout<<"\t\t\t\t\t\t*\n";

cout<<"\t\t_______________________________________ __________"<<endl;

cout<<endl;

cout<<"\t\t**********************\n";

cout<<"\t\t* enter the number *\n";

cout<<"\t\t**********************\n";

cout<<"\t\t\t\t\t"; cin>>n;

cin.ignore();

switch(n)

**

case 1:

system("cls");

cout<<endl;

cout<<"to insert data of car....\n";

insert (st);

break;

case 2:

system("cls");

cout<<endl;

cout<<"to sreaching about car in the company....\n";

sale (st);

break;

case 3:

system("cls");

cout<<endl;

cout<<"to sale car.....\n";

searching (st);

break;

case 4:

system("cls");

cout<<endl;

cout<<"to deleting car......\n";

deleting (st);

break;

case 5:

system("cls");

cout<<endl;

cout<<"to display data of car.......\n";

display (st);

break;

case 6:

system("cls");

cout<<endl;

cout<<"to search bout car sale.......\n";

search (st);

break;

default:

system("cls");

cout<<"try again...\n";

break;

}

}

while (n!=6);

}

void insert (car st[])

**

cout<<"enter the model of car :";

cin>>st.model;

cout<<"enter the code of the car:";

cin>>st.code;

cout<<"enter the color of the car :";

cin>>st.color;

cout<<"enter the power of engine :";

cin>>st.engine;

cout<<"enter the volume:";

cin>>st.volume;

i++;

void saving (car st []);

stfile.open("car.txt",ios::out|ios::in);

for (int f=-1;f<i;f++)

**

if (st.code!=0)

**

cout<<"the model of the car :"<<st.model<<endl;

cout<<"the code of the car:"<<st.code<<endl;

cout<<"the color of the car :"<<st.color<<endl;

cout<<"the power of engine of car:"<<st.engine<<endl;

cout<<"the volume of the car :"<<st.volume<<endl;

}

stfile.close();

}

}

void sale (car st[])

**

cout<<"enter the name of the cust.:";

cin>>st.name;

cout<<"enter the addresss of the cust.";

cin>>st.address;

cout<<"the num of cust:";

cin>>st.no;

cout<<"the cost of car:";

cin>>st.cost;

for (int s=-1;s<=i;s++)

**

if (st.no==s)

**

cout<<"the model of the car :"<<st.model<<endl;

cout<<"the code of the car:"<<st.code<<endl;

cout<<"the color of the car :"<<st.color<<endl;

cout<<"the power of engine of car:"<<st.engine<<endl;

cout<<"the volume of the car :"<<st.volume<<endl;

}

}

cin.get();

}

void searching (car st[])

**

long code,engine;

char color;

int i;

cout<<"enter the code of the car:";

cin>>st.code;

cout<<"enter the color of the car :";

cin>>st.color;

cout<<"enter the power of engine :";

cin>>st.engine;

for (int s=-1;s<=i;s++)

**

if (st.code!=0)

**

cout<<"the model of the car :"<<st.model<<endl;

cout<<"the code of the car:"<<st.code<<endl;

cout<<"the color of the car :"<<st.color<<endl;

cout<<"the power of engine of car:"<<st.engine<<endl;

cout<<"the volume of the car :"<<st.volume<<endl;

}

}

cin.get();

}

void deleting (car st[])

**

long l;

cout<<" write the code of the car which delete it:";

cin>>l;

system("cls");

for (int n=-1;n<=i;n++)

**

if(st[n].num==l)

**

st[n].num=0;

cout<<"the clear of the car datas complete"<<endl;

}

cin.get();

}

}

void search (car st[])

**

long code;

cout<<"write the code of the car which looks for it:";

cin>>code;

for (int s=-1;s<=i;s++)

**

if (st.code!=0)

**

cout<<"the model of the car :"<<st.model<<endl;

cout<<"the code of the car:"<<st.code<<endl;

cout<<"the color of the car :"<<st.color<<endl;

cout<<"the power of engine of car:"<<st.engine<<endl;

cout<<"the volume of the car :"<<st.volume<<endl;

}

}

cin.get();

}

void display (car st[])

**

for (int s=-1;s<=i;s++)

**

if (st.code!=0)

**

cout<<"the model of the car :"<<st.model<<endl;

cout<<"the code of the car:"<<st.code<<endl;

cout<<"the color of the car :"<<st.color<<endl;

cout<<"the power of engine of car:"<<st.engine<<endl;

cout<<"the volume of the car :"<<st.volume<<endl;

}

}

cin.get();

}

MATRIX

#2

السلام عليكم:

[background=#80FF80]
#include <iostream>
#include <process.h>
#include <fstream>
using namespace std;
fstream stfile;
class  car
{
public:
int num,volume,engine;
char color[10];
char model[10],name[10],address[10];
long cost,no,code;
};


int i=-1,s;
car st [10];

void insert (car []);
void sale (car []);
void searching (car []);
void deleting (car []);
void display (car []);
void search (car[]);
void main ()
    {
int n;
do
    {

system("cls");
cout<<endl;
cout<<endl;
cout<<"\t\t_______________________________________ __________"<<endl;
cout<<"\t\t*\t\t\t\t\t\t*\n";
cout<<"\t\t*\t\t\t\t\t\t*\n";
cout<<"\t\t*\t\t\t\t\t\t*\n";
cout<<"\t\t*\t1.inserting : \t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t2.Sale : \t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t3.searching : \t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t4.deleting : \t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t5.display : \t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t6.search the car sale : \t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t7.exit : \t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t\t\t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t_______________________________________ __________"<<endl;
cout<<endl;
cout<<"\t\t{{{{{{{{{{{\n";
cout<<"\t\t* enter the number *\n";
cout<<"\t\t{{{{{{{{{{{\n";
cout<<"\t\t\t\t\t"; cin>>n;
cin.ignore();

switch(n)
{
case 1:
system("cls");
cout<<endl;
cout<<"to insert data of car....\n";
insert (st);
break;

case 2:
system("cls");
cout<<endl;
cout<<"to sreaching about car in the company....\n";
sale (st);
break;

case 3:
system("cls");
cout<<endl;
cout<<"to sale car.....\n";
searching (st);
break;

case 4:
system("cls");
cout<<endl;
cout<<"to deleting car......\n";
deleting (st);
break;

case 5:
system("cls");
cout<<endl;
cout<<"to display data of car.......\n";
display (st);
break;

case 6:
system("cls");
cout<<endl;
cout<<"to search bout car sale.......\n";
search (st);
break;

default:
system("cls");
cout<<"try again...\n";
break;

}
}
while (n!=6);
}

void insert (car st[])
{

cout<<"enter the model of car :";
cin>>st.model;

cout<<"enter the code of the car:";
cin>>st.code;

cout<<"enter the color of the car :";
cin>>st.color;

cout<<"enter the power of engine :";
cin>>st.engine;

cout<<"enter the volume:";
cin>>st.volume;
i++;
void saving (car st []);
stfile.open("car.txt",ios::out|ios::in);
for (int f=-1;f<i;f++)
{
if (st.code!=0)
{
cout<<"the model of the car :"<<st.model<<endl;
cout<<"the code of the car:"<<st.code<<endl;
cout<<"the color of the car :"<<st.color<<endl;
cout<<"the power of engine of car:"<<st.engine<<endl;
cout<<"the volume of the car :"<<st.volume<<endl;
}

stfile.close();

}
}
void sale (car st[])
{
cout<<"enter the name of the cust.:";
cin>>st.name;
cout<<"enter the addresss of the cust.";
cin>>st.address;
cout<<"the num of cust:";
cin>>st.no;
cout<<"the cost of car:";
cin>>st.cost;
for (int s=-1;s<=i;s++)
{
if (st.no==s)
{
cout<<"the model of the car :"<<st.model<<endl;
cout<<"the code of the car:"<<st.code<<endl;
cout<<"the color of the car :"<<st.color<<endl;
cout<<"the power of engine of car:"<<st.engine<<endl;
cout<<"the volume of the car :"<<st.volume<<endl;
}
}
cin.get();
}


void searching (car st[])
{
long code,engine;
char color;
int i;
cout<<"enter the code of the car:";
cin>>st.code;
cout<<"enter the color of the car :";
cin>>st.color;
cout<<"enter the power of engine :";
cin>>st.engine;
for (int s=-1;s<=i;s++)
{
if (st.code!=0)
{
cout<<"the model of the car :"<<st.model<<endl;
cout<<"the code of the car:"<<st.code<<endl;
cout<<"the color of the car :"<<st.color<<endl;
cout<<"the power of engine of car:"<<st.engine<<endl;
cout<<"the volume of the car :"<<st.volume<<endl;
}
}
cin.get();
}



void deleting (car st[])
{
long l;
cout<<" write the code of the car which delete it:";
cin>>l;

system("cls");

for (int n=-1;n<=i;n++)
{
if(st[n].num==l)
{
st[n].num=0;
cout<<"the clear of the car datas complete"<<endl;
}
cin.get();
}
}
void search (car st[])
{

long code;
cout<<"write the code of the car which looks for it:";
cin>>code;
for (int s=-1;s<=i;s++)
{
if (st.code!=0)
{
cout<<"the model of the car :"<<st.model<<endl;
cout<<"the code of the car:"<<st.code<<endl;
cout<<"the color of the car :"<<st.color<<endl;
cout<<"the power of engine of car:"<<st.engine<<endl;
cout<<"the volume of the car :"<<st.volume<<endl;
}
}
cin.get();
}


void display (car st[])
{
for (int s=-1;s<=i;s++)
{
if (st.code!=0)
{
cout<<"the model of the car :"<<st.model<<endl;
cout<<"the code of the car:"<<st.code<<endl;
cout<<"the color of the car :"<<st.color<<endl;
cout<<"the power of engine of car:"<<st.engine<<endl;
cout<<"the volume of the car :"<<st.volume<<endl;
}
}
cin.get();
}


[/background]
tvquran_6.gif

#3

بارك الله فيك اخي والله ما قصرت وتسلم على ردك السريع والمميز

بس بدي اغلبك ضايل عندي فيه مشكلة في البرنامج وهيا كيف بدي احفظ المعلومات الي ادخلتها في ملف واستدعيها منه بدون ما كل مرة ادخل البيانات من اول وجديد

وبعدين فيه في المطلوب التالت الشراء كيف بدي اعمل كود انه لو بعت السيارة يظهر انه بعتها ولا لأ وسعرها وتاريخ الشراء واذا عملت بحث بعد ما تنباع ما تظهر في عملية البحث اذا بحثت عنها

MATRIX

#4

يا اخوان هادا كود لمشروع شركة سيارات عملته بس فيه بعض الاخطاس الي مش فاهمها يا ريت تساعدوني فيه بس بسرعة

#include<iostream.h>
#include<fstream.h>
class car
{
protected:
    int mots;
    int model;
    char name[20];
    char color[20];

public:

    void input (void)
    {

          int x;
          cout<<"enter the number of cars"<<endl;

          for(int i=0;i<x;i++)
          {
              cout<<"enter the name of car"<<endl;
              cin>>name;
              cout<<"enter the model of car"<<endl;
              cin>>model;
              cout<<"enter the motorspeed of car"<<endl;
              cin>>motsp;
              cout<<"enter the color of car"<<endl;
              cin>>color;

              datafile<<name;
              datafile<<model;
              datafile<<motsp;
              datafile<<color;

              name==0;
              model==0;
              motsp==0;
              color==0;
          }
         datafile.close();


    };

    class search 
    {
        char n[20];
    public:
        void sear (void)
        {
            cout<<"enter the name of car"<<endl;
            cin>>n;
            if(!datafile.eof() )
            {
                datafile<<name;
            if(n==name)
            {
                datafile<<name;
                cout<<name;
                datafile<<color;
                cout<<color;
                datafile<<model;
                cout<<model;
                datafile<<motosp;
                cout<<motosp;
            }
            else
                cout<<"we are sorry "<<endl;
            }
        };

        class cast 
        {
        private:
            char v[20];
            char add[20];
            int ph;
            char c[20];
            float mony;
            char day[20];

        public:
            void castam;
            {
                cout<<"enter your name "<<endl;
                cin>>v;
                cout<<"enter your address "<<endl;
                cin>>add;
                cout<<"enter your phone number "<<endl;
                    cin>>ph;
                cout<<"how many you will buy the car"<<endl;
                cin>>mony;
                cout<<"enter the name of car you will buy it"<<endl;
                cin>>c;
                cout<<"enter the day youwill buy in it"<<endl;
                cin>>day;

                fstream text;

                text.open("castamer.txt",ios::out);
                text<<v;
                text<<add;
                text<<ph;
                text<<mony;
                text<<c;
                text<<day;
            }


            void shsel; 
            {
                while(!text.eof(0))
                {
                text<<v;
                cout<<v<<endl;
                text<<add;
                cout<<add<<endl;
                text<<ph;
                cout<<ph<<endl;
                text<<mony;
                cout<<mony<<endl;
                text<<c;
                cout<<c<<endl;
                text<<day;
                cout<<day<<endl;
                }
            }

        };








void main()

{
        fstream datafile ;
        datafile . open("cars.txt", ios::in | ios::app);
    int n;
cout<<"\t\t*\t1.inserting : \t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t2.Sale : \t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t3.searching : \t\t\t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";
cout<<"\t\t*\t5.search the car sale : \t\t*\n\t\t*";
cout<<"\t\t\t\t\t\t*\n";

switch(n)
{
case 1:
car ncar;
ncar.input();
break;

case 2:
cast ho;
ho.castam();
break;

case 3:
search gh;
gh.sear();
break;



case 4:
cast lo;
lo.shsel();

break;

default:
system("cls");
cout<<"try again...\n";
break;

}

تم تعديل هذه المشاركة بواسطة رغـــــــــد في 16 يونيو 2008 في 19:26 — السبب: رجاء اخي ضع الشيفرة بالصندوق هيك

MATRIX

#5

خلص اخي احمد انا ناقلته هون..تفضل باشر موضوعك وحاطة الشيفرة كمان بالصندوق..وآسفة لإزعاجك. لكن المرة الجية بترجاك --> مراعاة هذي الضوابط و شكراً

,.,.,.,.,.,.,.,.,.

تم تعديل هذه المشاركة بواسطة رغـــــــــد في 16 يونيو 2008 في 19:44 — السبب: تعديل الصيغة

[وسط]

♥ Countess ♥

57899411.gif

♥

[/وسط]

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

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

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

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

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