}
/* END OF 'SetText' OVERLOADED METHOD */
/* THIS IS OVERLOAD OF 'SetText' METHOD */
void SetText (STR text)
{
FirstText.length = text.length;
memmove (FirstText.text, text.text, FirstText.length);
BuildedText = false;
}
/* END OF 'SetText' OVERLOADED METHOD */
/* THIS METHOD BUILD TEXT */
/* THIS METHOD IS NOT YET COMPLIETED */
void BuildText (void)
{
BuildedText = true;
DeleteComents ();
ReduceSpaces ();
DeleteLines ();
}
/* END OF 'BuildText' METHOD */
/* THIS METHOD RETURNS CURRENT WORD IN TEXT */
/* THIS METHOD IS NOT YET COMPLIETED */
STR GetWord (void)
{
STR OutPut = {0, NULL};
if (!BuildedText)
return OutPut;
if ( OutText.text [POSITION] == ' ' )
POSITION++;
if ( isalpha (OutText.text[POSITION]))
{
OutPut.text = (char*)malloc (OutPut.length = 1);
OutPut.text [0] = OutText.text [POSITION++];
while ( isalpha (OutText.text [POSITION]) || isdigit (OutText.text [POSITION]) )
{
OutPut.text = (char*)realloc (OutPut.text, OutPut.length + 1);
OutPut.text [OutPut.length++] = OutText.text [POSITION++];
}
OutPut.text = (char*)realloc (OutPut.text, OutPut.length + 1);
OutPut.text [OutPut.length] = '\0';
}
else if (isdigit (OutText.text [POSITION]) )
{
OutPut.text = (char*)malloc (OutPut.length = 1);
OutPut.text [0] = OutText.text [POSITION++];
while (isdigit (OutText.text [POSITION]))
{
OutPut.text = (char*)realloc (OutPut.text, OutPut.length + 1);
OutPut.text [OutPut.length++] = OutText.text [POSITION++];
}
OutPut.text = (char*)realloc (OutPut.text, OutPut.length + 1);
OutPut.text [OutPut.length] = '\0';
}
else if ( IsPriority (OutText.text [POSITION]) )
{/**/
short kindprt = KindOfPriority (OutText.text [POSITION]);
short Nkindprt = KindOfPriority (OutText.text [POSITION + 1]);
//if (kindprt ==)
}/**/
return OutPut;
}
/* END OF 'GetWord' METHOD */
/* THIS METHOD RETURNS OUTPUTTEXT */
STR GetText (void)
{
STR FalseText = {0, "Please Use 'BuildText' Method"};
if (BuildedText)
return OutText;
return FalseText;
}
/* END OF 'GetText' METHOD */
/********************************************************************
END OF PUBLIC MEMBERS DEFINITIONS
********************************************************************/
};
#endif
5. Результаты:
6. Выводы:
Научились использовать классы и их методы на примере класса «насекомое».
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.