Create an object oriented design of the following system. Your design should inc
ID: 3798902 • Letter: C
Question
Create an object oriented design of the following system. Your design should include classes, attributes, methods, relationships (associations) among the classes.
The following brief problem statement was developed by David Parnas in 1972[1]: The KWIC [Key Word in Context] index system accepts an ordered set of lines; each line is an ordered set of words, and each word is an ordered set of characters. Any line may be “circularly shifted” by repeatedly removing the first word and appending it at the end of the line. The KWIC index system outputs a listing of all circular shifts of all lines in alphabetical order.
I want to modify this slightly by adding that this system should only do the circular shift for nouns. Thus, it will have to track nouns and non-noun words.
Explanation / Answer
Classes:
1)
class word
{
char array_myword[]; // a word is array of words
}
2)
class line
{
word arrayLine[] // list of words
}
3)
class context
{
line array_context[] ; // List of lines
}
Methodes:
1) function to check is a word is noun or not
bool isnoun( word w)
{
if(w is a noun)
{
return true;
}
else
{
return false;
}
}
2) Function to circulary shift a line
void shift_line(line l)
{
if( isnoun(l[0]))
{
tmp = l[0];
for(int i = 1; i < l.size(); i++)
{
l[i-1] = l[i];
}
l[n-1] = tmp;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.