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

اريد مساعدتي في فهم وحل السؤال

مغلق
بدأه أصيل البرمجة في 9 يونيو 2006 · 4 رد · 517 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

الاسلام عليكم , اريد مساعدتي في فهم هذان السؤالين المطلوب تنفيذه امام الطالبات, اي اريد ما المطلوب مني بالضبط

السؤال الاول

Topic 1:

 Object-oriented programming depends on the concept of classes. An important advantage of using classes is to obtain data encapsulation. In C++ this is achieved with the ‘private’ and ‘public’ keywords. Explain which parts of a class are generally made public, which are made private, and how they are used/accessed.

 You may use JAVA instead of C++ if you prefer.

Assumptions:

 The students know structured programming, pointers, and arrays.

 The students are just beginning to learn about objects.

 They already know that an object has member variables and member functions.

 They know what constructors are.

Scenario:

 The students were given a sheet a few days earlier.

 In the sheet they are asked to extend a class for an object called basket (see below) that depending on its size can hold a different number of items. They are asked to write a member function that allows adding items to the basket while it is not full and another one that allows checking whether the basket is full or not.

class basket

{public:

basket(int s)

{

size=s;

items = (int*)calloc(s,sizeof(int));

}

private:

int *items;

int current; // current number of items

int size; // size of basket

}

السؤال الثاني

Topic 2:

 Data Structures are the basis for many programming concepts.

 A major data structure that needs to be mastered by students is a binary search tree.

Assumptions:

 The students know basic programming, pointers, and arrays.

 Some of the students are weak with regard to pointers specially when it comes to differentiating between when to use (.) vs. (->)

 They know what a binary search tree is.

Scenario:

 The students were given a sheet a few days earlier.

 In the sheet they are asked to trace the insertion of an element into a binary search tree that is implemented with pointers.

 You are now entering the class to give a tutorial lesson

class Node

{

public:

Node( char e)

{

element = e;

right = NULL;

left = NULL;

}

Node *right;

Node *left;

char element;

};

class BST

{

public:

BST(){root=NULL;}

void insert(char e)

{

// check if it is the first element

if(root==NULL)

{ root = new Node(e);

return;

}

Node *current,*previous;

current = root;

previous = current;

// move to the correct position

while (current!= NULL)

{ previous = current;

if (e>current->element)

current = current->right;

else

current = current->left;

}

// create the new node and attach it

current = new Node(e);

if(e>previous->element)

previous->right=current;

else

previous->left=current;

}

Node *root;

};

void main()

{

BST myTree;

myTree.insert('o');

myTree.insert('a');

myTree.insert('z');

myTree.insert('y');

return;

}

#2

السؤال الأول:

أكتبى دالتين زيادة فى الكلاس دى

1. دالة تسمح بإضافة عناصر إلى ال basket إذا كان فيها مكان.

2. دالة تسمح بالتأكد إذا كانت السلة مليانة أم لا.

السؤال الثانى: أنا مش شايف إنه طالب منك حاجة !! :D أو مش فاهم هو عايز إيه!!

#3

مشكوووووووور على المساعدة

#4

ممكن يا اخي اعرف منك كيف بتكتب لاسئله وبتبعتوها للرد عليها من لاعضاء

واكون من الشاكرين

ART(1).JPG

innocentmoon_sh@hotmail.com

من السهل ان يشتاق لانسان لمن يحب ....................

لكن من الصعب ان يجده كلما اشتاق اليه.................

your frand.....

silent hill

#5

silent hill

لو سمحت ما فهمت وش تقصد بالضبط؟؟؟؟

هذا الموضوع مغلق.

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