Exercise Computing the cyclomatic complexity Philippe CHARMAN Last update:
Exercise Draw the control flow graph of the following function What is the value of its cyclomatic complexity Use another method to compute it and check the value is the same
void Library::RemoveSubscriber(int code_sub) { Position pos = SubList.getHeadPostition(); while (pos) { if (code_sub == SubList.getAt(pos).getCode()) { if (SubList.getAt(pos).getExpirationDate() == 0) { if (SubList.getAt(pos).getBooks() == 0) { SubList.getAt(pos).removeSubscriber(); cout << “The subscriber has been removed” << endl; return; } else { cout << “Books must be returned first” << endl; return; } else { cout << “The subscriber is already removed” << endl; return; } else { SubList.getNext(pos); } cout << “This subscriber doesn’t exist” << endl; }