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

الرجاء المساعدة في اكمال هذا البرنامج

بدأه ibu_love في 10 يناير 2009 · 2 رد · 548 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم اخواني الاعضاء الرجاء المساعدة في إكمال هذا البرنامج..

خطوات البرنامج هي:-

The main class is named person , Two classes inheritant from the main class (Student ,Employee)

-The members of the main class are :Identifier Id ,name ,Sex

- The Member of the Student :student number , the Specialization of the student

- The member of the class employee : employee number ,the work he do

- Using the overload Function in output and input .

- Using the writeload Function in the print Function.

- Insert at lest 10 student and 10 employees

- Print the list of the employees as a table with all own data.

- Print the list of the Students as a table with all own data.

- The proportion of male to female in the employee

-After finish built a destructor function to destruct all the objects in the class.

الذي استطعت كتابته ..

#define male 'm'  
#define female 'f'  

#include <iostream>  
#include <cstdlib>  
#include <ctime>  
#include <string>  
using namespace std;  

class person  
{  
public:  
	person(int,char,string);  
	person();  
	int id();  
	char sex();  
	string name();  
	int changename(string);  
	static int reset_count();  
protected:  
	int person_id;  
	char person_sex;  
	string person_name;  
	static int count;  
};  

class student: public person  
{  
public:  
	student (string,char);  
	student (string,char,char);  
	int number();  
	char specialization();  
protected:  
	int student_number;  
	char student_specialization;  
};  

class employee: public person  
{  
public:  
	employee (int,char);  
	employee (string,char,char);  
	int number ();  
	char working ();  
protected:  
	int employee_number;  
	char employee_working;  
};  

int person::count;  

int person::reset_count() {  
	person::count=0;  
	return (person::count);  
}  

person::person(int a, char b, string c)  
{  
	person_id=person::count;  
	person::count++;  
	person_sex=b;  
	person_name=c;  
}  

person::person()  
{  
	person_id=person::count;  
	person::count++;  
	char this_persons_sex;  
	int random=rand()%2;  
	if (random==0) this_persons_sex='m';  
	else this_persons_sex='f';  
	person_sex=this_persons_sex;  
	person_name="";  
}  


int person::id()  
{  
	return (person_id);  
}  

char person::sex()  
{  
	return (person_sex);  
}  

string person::name()  
{  
	return (person_name);  
}  

int person::changename(string a)  
{  
	person_name=a;  
	return 0;  
}  


student::student(string a, char b )  
{  
	student_number=person_id;  
	person_name=a;  
	student_specialization=b;  
}  

student::student(string a, char b, char c )  
{  
	person_name=a;  
	student_number=person_id;  
	student_specialization=b;  
	person_sex=c;  
}  

int student::number()  
{  
	return (student_number);  
}  

char student::specialization()  
{  
	return (student_specialization);  
}  

employee::employee(int a, char b )  
{  
	employee_number=a;  
	employee_working=b;  
}  

employee::employee(string a, char b, char c )  
{  
	person_name=a;  
	employee_number=person_id;  
	person_sex=b;  
	employee_working=c;  
}  

int employee::number()  
{  
	return (employee_number);  
}  

char employee::working()  
{  
	return (employee_working);  
}  

int main()  
{  
	person::reset_count();  
	srand(time(NULL));  
	employee ** emp;  
	student ** stu;  
	char tmpsex;  
	string tmpname;  
	string junk;  
	char tmpspec;  
	emp=new employee*[10];  
	stu=new student*[10];  

	cout<<"students:"<<endl;  
	for (int i=0;i<10;i++)  
	{  
		cout<<"name: ";  
		getline(cin,tmpname);  
		cout<<"specialization: ";  
		cin >> tmpspec;  
		cout<<"sex: ";  
		cin >> tmpsex;  
		getline(cin,junk); // clear input buffer from junk cin leaves there  
		stu=new student(tmpname,tmpspec,tmpsex);  
	}  
	cout<<"employees:"<<endl;  
	for (int j=0;j<10;j++)  
	{  
		cout<<"name: ";  
		getline(cin,tmpname);  
		cout<<"sex: ";  
		cin>> tmpsex;  
		cout << "Working?: ";  
		cin >> tmpspec;  
		getline(cin,junk);  
		emp=new employee(tmpname,tmpsex,tmpspec);  
	}  
	cout << "Student Data:\nid\tname\tsex\tspecialization\n";  
	cout<<"-------------------------------------------------------------------------"<<endl;  
	for (int k =0; k<10;++k)  
	{  
		cout<<stu->id()<<"\t"<<stu->name()<<"\t"<<stu->sex()<<"\t"<<stu->specialization()<<endl;  
	}  
	cout<<"-------------------------------------------------------------------------"<<endl;  
	cout << "\nEmployee Data:\nid\tname\tsex\tworking\n";  
	cout<<"-------------------------------------------------------------------------"<<endl;  
	for (int z =0; z<10;++z)  
	{  
		cout<<emp->id()<<"\t"<<emp->name()<<"\t"<<emp->sex()<<"\t"<<emp->working()<<endl;  
	}  
	cout<<"-------------------------------------------------------------------------"<<endl;  
	cout<<"\n\nPress <ENTER> to Exit. ";  
	cin.get();  
	return 0; }

سؤالي :-

هل قمت بتنفيذ جميع الخطوات المطلوبة ؟؟

باستثناء..

آخر فقرة لم استطع كتابتها وهي القيام بـ destructor لـ objects

يعني عملية الهدم للأوبجيكتس

وأيضا اضافة الـ headers للبرنامج

أرجو الله أن أجد بينكم اخوتي من يساعدني

تحياتي

تم تعديل هذه المشاركة بواسطة ibu_love في 10 يناير 2009 في 13:40

FineDesign For Graphic and WebDesign

ForEach(Minute in MyLife)

MyExperience ++;

#2

وين الردود يا شباب؟؟

أخوي فهـد الشلوي السادة الاعضاء الرجاء المساعدة

تحياتي

FineDesign For Graphic and WebDesign

ForEach(Minute in MyLife)

MyExperience ++;

#3

السلام عليكم.

أخي اكتب السؤال كامل بالعربي .

ثم ما معنى تضيف الهدر اي هدر.

لديك في الداله الرئسية بعض الاخطاء البسيطه الواضحه في اسما متغيرات الفور.

tvquran_6.gif

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

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

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

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

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