PDA

View Full Version : سوال: (کمک)‌کلاس set با کمک الگو و استثناها



Jeren2
پنج شنبه 03 آذر 1390, 15:13 عصر
سلام . آیا امکانش هست کمک کننی من این برنامه رو بنویسم؟ باید یه کلاس به اسم ست درست کنم با متد های زیر .



I am expected to create the following classes:
• Set<T>: Set.h


“Set” is a template class that represents a set in mathematics. A set in this homework can only contain items of same type. In other words, if a set is a “set of integers” it cannot contain “char”s, “float”s or
“double”s etc.


Methods
• void add(const T& item)throw(SetException) Adds an item to the set. Throws an instance of “Se-
tException” class if the “item” already exists. Error code is “ITEM ALREADY EXISTS”, and
message is “Item already exists”.

• void remove(const T& item)throw(SetException) Removes an item from the set. Throws an instance
of “SetException” class if the “item” does not exists. Error code is “ITEM NOT EXISTS”, and
message is “Item does not exist”.

• bool exists(const T& item)const Returns true if an item exists in the set, returns false otherwise.
• int cardinality()const Returns the number of elements in the set.

• std::vector<T> toSortedVector()const Returns the set as an std::vector with items sorted in in-
creasing order.

thannks


I am only alllowed to use STL algorithms and not allowed to use STL “Set” class!

Jeren2
پنج شنبه 03 آذر 1390, 15:16 عصر
البته کل قضیه اینه .. فایلش رو اتچ کردم .. اما یه مقدار اولش رو راه بیوفتم قضیه دستم میاد :خجالت: