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

شرح سؤال

مغلق
بدأه انثى خجوله في 18 فبراير 2012 · 2 رد · 635 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

تحياتي العطره لكم

لدي سؤال احتاج من يشرح لي

A sentence can be defined as a group of words. Develop a Sentence Class according to the following:

• Assume the maximum number of words in a sentence is five.

• The sentence should be empty at the beginning. Then, the user should add the word in the order. I.e. The user can not add the second word while the first word is empty and so on.

• Your class should include the following member functions:

o AddWord(): add a received word at the end of the sentence. The function should return true when the word is inserted correctly and false otherwise.

o Size() : which returns the number of words in the sentence.

o PrintSentence() : print the sentence.

o ReplaceFirstWord() : replace the first word by a received word.

o ReplaceLastWord(): replace the last word in a sentence by a received word

• Separate the class interface from implementation.

• To test your class write a main() function that define a sentence of a t least three words. Try to call all functions.

تقبلوا تحياتي

1
#2

السلام عليكم يمكن ان تكون مساعدى مفيدة شئ ماء :

مخطط UML للسؤال يمكن طرحة بالشكل التالى:

post-247365-001711900 1329816185_thumb.p

وعند تحويل المخطط السابق الى كود سي++ بأستخدام برنامج Umbrello UML Modeller Version 2.5.5 فأن الكود يكون كالتالى طبقا للشرط اﻻخير بالتمرين وهو :

اقتباس
• Separate the class interface from implementation.

كود ملف: Sentence.h

#ifndef SENTENCE_H
#define SENTENCE_H

#include <string>

/**
  * class Sentence
  * generated by dia/codegen.py
  */

class Sentence
{
public:

  /**
  default constratoc
   */
   Sentence ( )
   {

   }

  /**
   * @return bool
   * @param  StrWord
   */
  bool AddWord (string StrWord );

  /**
   * @return int
   */
  int Size ( );

  /**
   */
  void PrintSentence ( );

  /**
   * @return bool
   * @param  StrNewWord
   */
  bool ReplaceFirstWord (string StrNewWord );

  /**
   * @return bool
   * @param  StrNewWord
   */
  bool ReplaceLastWord (string StrNewWord );

private:

  // Private attributes
  //  
  string* WordsList;

};

#endif // SENTENCE_H

ملف : Sentence.cpp

#include "Sentence.h"

//  
// Methods
//  

// Accessor methods
//  

// Other methods
//  

/**
 */
 Sentence::Sentence ( )
{
}

/**
 * @return bool
 * @param  StrWord
 */
bool Sentence::AddWord (string StrWord )
{
}

/**
 * @return int
 */
int Sentence::Size ( )
{
}

/**
 */
void Sentence::PrintSentence ( )
{
}

/**
 * @return bool
 * @param  StrNewWord
 */
bool Sentence::ReplaceFirstWord (string StrNewWord )
{
}

/**
 * @return bool
 * @param  StrNewWord
 */
bool Sentence::ReplaceLastWord (string StrNewWord )
{
}

طبعا ممكن تضيفى اكوادك بسلاسلة للملفين السابقين وﻻ ننسى ملف البرنامج الرئيسى main.cpp

تقبل مرورى والله ولى التوفيق .

المرفقات
Screenshot.png

post-15367-027053900%201340345097.gifpost-15367-087183200%201340344597.gif
post-247365-0-10080400-1379403554_thumb.

#3
اقتباس
لدي سؤال احتاج من يشرح لي

هل تريدين ترجمة السؤال إلى العربية ؟ أم شرح السؤال من الناحية البرمجية ؟؟

هذا القسم مختص بالبرمجة بلغتي السي و السي++ و ليس قسم ترجمة. هذه المرة العاشرة التي تضعين فيها سؤال باللغة الإنجليزية و هذا مخالف لقوانين القسم.

أرجوا من الإخوة النظر بجدية في هذا الموضوع.

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

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