Please help finish this problem for a rolodex program. each level needs to work so please indicate
Question:
Please help finish this problem for a rolodex program. each level needs to work so please indicate where code for level 1,2 & 3 is written.
code for main.cpp: (wrong, please fix)
#include
#include
#include
#include
bool verbose = false; // report actions
bool noDuplicates = false;
bool report = false;
bool alphabetic = false;
bool sequence = true;
int main(int argc, char **argv)
{
int c;
while ((c = getopt(argc, argv, \"vdras\")) != EOF)
{
switch (c)
{
case 'v':
verbose = true;
break;
case 'd':
noDuplicates = true;
break;
case 'r':
report = true;
break;
case 'a':
alphabetic = true;
break;
case 's':
sequence = true;
break;
}
}
argc -= optind;
argv += optind;
std::string word;
Rolodex rolodex;
int found;
int overriderPlus;
std::string badWord;
while (cin >> word)
{
found = 0;
overriderPlus = 0;
badWord = \"?\";
if (word.front() == '+')
{
overriderPlus = 1;
word.erase(word.begin());
}
}
if (word.front() == '-')
{
word.erase(word.begin());
badWord = word;
}
if (rolodex.isBeforeFirst() || check(rolodex.currentValue(), word, '#', alphabetic))
{
while (!rolodex.isAfterLast() && check(rolodex.currentValue(), word, '',>
{
rolodex.rotateForward();
if (verbose) cerr
cerr
}
if (noDuplicates)
{
if (check(rolodex.currentValue(), word, '=', alphabetic))
{
found = 1;
}
}
if (check(rolodex.currentValue(), badWord, '=', alphabetic)) { rolodex.deleteCurrent();
}
else if (found == 0 || overriderPlus == 1) { rolodex.insertBeforeCurrent(word);
}
if (verbose) { cerr
}
}
else if (rolodex.isAfterLast() || check(rolodex.currentValue(), word, '$', alphabetic))
{
while (!rolodex.isBeforeFirst() && check(rolodex.currentValue(), word, '>', alphabetic))
{
rolodex.rotateBackward();
if (verbose) cerr
cerr
if (check(rolodex.currentValue(), word, '=', alphabetic))
{ found = 1;
}
}
if (check(rolodex.currentValue(), badWord, '=', alphabetic)) { rolodex.deleteCurrent();
}
else if (found == 0 || overriderPlus == 1) { rolodex.insertAfterCurrent(word);
}
if (verbose) cerr
}
}
int getopt(int argc, char **pString, const char string[6]) {
return 0;
}
if (report == true)
{
cout
cout
cout
}
rolodex.rotateForward();
// go to first card while (!rolodex.isAfterLast()) { if (sequence) cout
// NOT TOO SURE WHAT SHOULD BE INSIDE currentOrder??? cout
code for Rolodex.cpp:(please fix)
#include \"Rolodex.h\"
#include
#include
# include
using namespace std; //sets a string to all uppercase
string toUpper(string s)
{
string upper = s;
}
for (int i = 0; i
upper[i] = toupper(upper[i]);
return upper; } //checks equality between two strings
bool check(string value, string word, char op, bool alphabetic)
{
if (alphabetic)
{
switch (op)
{
case '=': return toUpper(value) == toUpper(word);
case '':>
case '#': return toUpper(value) =>
case '$': return toUpper(value) >= toUpper(word);
case '>': return toUpper(value) > toUpper(word);
}
}
}
else
{
switch (op)
{
case '=': return value == word;
case '':>
case '#': return value =>
case '$': return value >= word;
case '>': return value > word;
}
}
}
bool verbose = false; // report actions
bool noDuplicates = false;
bool report = false;
bool alphabetic = false;
bool sequence = true;
code for Rolodex.h:
#ifndef ROLODEX_H
#define ROLODEX_H
#include
#include
using namespace std;
template
class Rolodex {
public:
/**
* Creates a new empty Rolodex.
*/
explicit Rolodex();
/**
* Returns true if the Rolodex is positioned before the first card.
*/
bool isBeforeFirst() const;
/**
* Returns true if the Rolodex is positioned after the last card.
*/
bool isAfterLast() const;
/**
* Rotates the Rolodex one card forwards.
*/
void rotateForward();
/**
* Rotates the Rolodex one card backwards.
*/
void rotateBackward();
/**
* Returns the value of the current card.
*/
const std::string& currentValue() const;
/**
* Inserts a new card after the current card and positions the Rolodex
* at the newly inserted card.
*
* @param value The value to insert into a new card.
*/
void insertAfterCurrent(const std::string& value);
/**
* Inserts a new card before the current card and positions the Rolodex
* at the newly inserted card.
*
* @param value The value to insert into a new card.
*/
void insertBeforeCurrent(const std::string& value);
private:
// Add instance variables here
};
#endif //ROLODEX_H