Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I\'m working on a project from class, and it\'s a text analysis project.

ID: 3556562 • Letter: H

Question

Hello, I'm working on a project from class, and it's a text analysis project. We're supposed to load a document into the program and basically read data from it. Ex: (word count, sentence count, etc.)

For some reasons, I get this error in my Document.h in line 24: 'Line' no appropriate default constructor available

1. How can I fix this?

2.Create a function in Line called parseWords that returns an array of strings containing words for the
Line.
Create a function in Line called parseChar that takes in value and returns an array of chars. This
array should be ?lled with the characters from the Line.

3. I am supposed to add a function called outputDocument in class Document. It's supposed to takes in a string and outputs the document to a ?le at a location given by the string. I implemented that into my code, but I was wondering if I did it right.

Line.h

http://pastebin.com/WmYD0XbU

Line cpp

http://pastebin.com/dCJRfcW8

Document cpp

http://pastebin.com/TGnNPGAi

Document h

http://pastebin.com/gcJsyaMn

main

http://pastebin.com/CrAhAm2r

Explanation / Answer

For some reasons, I get this error in my Document.h in line 24: 'Line' no appropriate default constructor available

1. How can I fix this?

#include <iostream>
#include <fstream>
#include <string>
#include "Line.h"

// Default Constructor
Line::Line()
{
   int id = rand();
   string* str = new string;
//   Line* line = new Line[4]; // this line is causing issue..remove this line.
// u cant call same constructor from same class.....

}

// Destructor
Line::~Line()
{
   delete str;
}

//set string
void Line::setStr(string str1)
{
   *str = str1;
}

//counts the word in a sentence and returns the word count.
int Line::getWordCout()
{
   char c = '';
  
   if (wordcout == 0)
   {
       while (c != '.' && c != '?' && c != '!')
       {
           if (c = ' ')
               wordcout++;

       }
  
       return wordcout;
   }
   else
       return wordcout;
}

//sets the word count
void Line::setWordCount(int value1)
{
   wordcout = value1;
}


// gets the number of chars in a line
int Line::getCharCount()
{
   return charcount;
}

// sets the number of chars in a line
void Line::setCharCount(int value2)
{
   charcount = value2;
}

// returns an array of strings containing words for the Line

/* int Line::parseWords ()
{
return 0; // returns 0 for now
}

// returns an array of chars
int Line::parseChars ()
{
   return 0;
} */


2.Create a function in Line called parseWords that returns an array of strings containing words for the
Line.

int Line::parseWords(String* str)
{
   str = new String[wordcout];
   stringstream new_str(str);
   string local;
   int index = 0;
   while(new_str >> local)
   {
   str[index++] = local;
   }
   return wordcout;
}

Create a function in Line called parseChar that takes in value and returns an array of chars. This
array should be ?lled with the characters from the Line.

int Line::parseChar(char* ch)
{
   ch = new char[charcount+1];

    int i;
   for(i=0; i<str.length(); i++)
   ch[i] = str[i];

   ch[i] = '';

return charcount;
}


3. I am supposed to add a function called outputDocument in class Document.
It's supposed to takes in a string and outputs the document to a ?le at a location given by the string.
I implemented that into my code, but I was wondering if I did it right.

void Document::outputDocument(string name, string str)
{
   ofstream myfile;
   myfile.open (name.c_str(), ios::in);

   myfile << str << endl;

   myfile.close();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote