patterncppMinor
Chack miy spellang pleez
Viewed 0 times
miypleezspellangchack
Problem
For my CS2 project, I am supposed to implement a spell-checker. It is
supposed to follow the following:
of correctly spelled words
Prompt the user for the name of a file to spell check
and the dictionary
Warning: there is a lot of code below, if reviewers don't want to go through all of the other code, please just focus on my
```
#ifndef SET_INTERFACE
#define SET_INTERFACE
#include
/** @class SetInterface SetInterface.h "SetInterface.h"
*
* Definition of SetInterface class template.
*/
template
class SetInterface
{
public:
/** Virtual destructor. */
virtual ~SetInterface() {}
/** Gets the current number of entries in this set.
* @return The integer number of entries currently in the set.
*/
virtual int size() const = 0;
/** Sees whether this set is empty.
*
* @return True if the set is empty, or false if not.
*/
virtual
supposed to follow the following:
- Prompt the user for the name of the file containing the dictionary
of correctly spelled words
- Read in the name of their dictionary file
- Open an input file stream on their filename
- If their filename successfully opens:
- For each word in the dictionary file:
- Add the word to the
dictionaryLinkedSet
- Close the dictionary file
- Do while the user wants to spell check files:
Prompt the user for the name of a file to spell check
- Read in the name of their file
- Open an input file stream on their file
- If the file successfully opens
- For each word in their file:
- Clean the word of extraneous characters
- Convert the word to lowercase
- Add the word to the
fileBeingSpellCheckedLinkedSet
- Close the file being spell checked
- Create a
LinkedSeton the difference of thefileBeingSpellChecked
and the dictionary
- Display the contents of the difference
LinkedSet
- Clear the
fileBeingSpellCheckedLinkedSet
- Clear the difference
LinkedSet
- Prompt the user whether they want to spell check another file
- Get their response
- Quit
Warning: there is a lot of code below, if reviewers don't want to go through all of the other code, please just focus on my
main.cpp file.SetInterface.h:```
#ifndef SET_INTERFACE
#define SET_INTERFACE
#include
/** @class SetInterface SetInterface.h "SetInterface.h"
*
* Definition of SetInterface class template.
*/
template
class SetInterface
{
public:
/** Virtual destructor. */
virtual ~SetInterface() {}
/** Gets the current number of entries in this set.
* @return The integer number of entries currently in the set.
*/
virtual int size() const = 0;
/** Sees whether this set is empty.
*
* @return True if the set is empty, or false if not.
*/
virtual
Solution
(if existant)
Spellin errah!
-
Along the same line I would argue that
is
in disguise.
-
Spellin errah!
-
void displaySet(LinkedSet set) wants to be std::ostream& operator&);Along the same line I would argue that
while(lineStream >> word)
{
dictionary.add(word);
}is
std::istream operator>>(std::istream, LinkedSet&)in disguise.
-
difference is suboptimal. If it is OK to convert LinkedSets to vectors, it is surely OK to sort the vectors.Code Snippets
std::ostream& operator<<(std::ostream&, const LinkedSet<T>&);while(lineStream >> word)
{
dictionary.add(word);
}std::istream operator>>(std::istream, LinkedSet<T>&)Context
StackExchange Code Review Q#83054, answer score: 3
Revisions (0)
No revisions yet.