Question

13.13 Final - Problem 2 (Chapter 8) Google Docs (20 points) Given the Document class below,...

13.13 Final - Problem 2 (Chapter 8)

Google Docs (20 points)

Given the Document class below, you will write a basic version of Google Drive. Your program will store two lists of documents, one for documents the user has created and one for created documents the user has shared with a friend. The user will have a few options which you will need to implement (note: the menu will only be displayed once at the beginning of the program):

  • Add a document to the user's list:
    • Allow the user to enter the document name, document extension, and document contents and then add that Document to the list of documents

Example Input/Output:

Choose an option below: 
1. Add a document to your list
2. Rename one of your documents
3. Share one of your documents with your friend
4. Display all of the documents
5. Quit
1
Enter the document name: 
MainLab1
Enter the document extension: 
doc
Enter the document content: 
#include <iostream> ....
Enter option: 
  • Rename one of the user's documents
    • Allow the user to enter the index of the document in their list they want to rename
    • Allow the user to enter the updated name of that document
    • Set the name of the document to be the updated name they enter

Example Input/Output:

Enter option: 
2
Enter the index of your document you want to rename: 
3
Enter the updated name of the document: 
MainLab3
Enter option: 
  • Share one of the user's documents with a friend
    • Allow the user to enter the index of their document they want to share with their friend

Example Input/Output:

Enter option: 
3
Enter the index of your document you want to share: 
6
Enter option: 
  • Display all the documents in both the user's and the friend's list.
    • Print all the information about all the documents in the user's list
    • Print all the information about all the documents in the friend's list

Example Input/Output:

Enter option:
4
-------------------Your List------------------
Name: MainLab1.cpp
Contents: #include <iostream> ....
Name: REL_A_131_Paper.doc
Contents: In the Book of Mormon, one of the main...
Name: American-Heritage-Study-Guide.doc
Contents: The Spanish Armada was a...
Name: Physical_Science_100.ppt
Contents: Slides for Physical Science Presentation...
--------------Your Friend's List--------------
Name: American-Heritage-Study-Guide.doc
Contents: The Spanish Armada was a...
--------------------------------------------

Think about what type of object you want your vectors to store (hint: you want any change in the document you share with your friend to change in your list AND their list). At the end of the program, free up any memory you may have allocated. Note - do not worry about error checking for invalid indexes.

Deductions:

  • Failure to delete all the memory off the heap at the end of the program (10 points)
  • Failure to use pointers (25 points)

Full Example Input/Output:

Choose an option below: 
1. Add a document to your list
2. Rename one of your documents
3. Share one of your documents with your friend
4. Display all of the documents
5. Quit
1

Enter the document name: 
MainLab1
Enter the document extension: 
cpp
Enter the document content: 
#include <iostream> ....

Enter option: 
1
Enter the document name: 
REL_A_131_Paper
Enter the document extension: 
doc
Enter the document content: 
In the Book of Mormon, one of the main...

Enter option: 
1
Enter the document name: 
American-Heritage-Study-Guide
Enter the document extension: 
doc
Enter the document content: 
The Spanish Armada was a...

Enter option: 
1
Enter the document name: 
Physical_Science_100
Enter the document extension: 
ppt
Enter the document content: 
Slides for Physical Science Presentation...

Enter option: 
4
-------------------Your List------------------
Name: MainLab1.cpp
Contents: #include <iostream> ....
Name: REL_A_131_Paper.doc
Contents: In the Book of Mormon, one of the main...
Name: American-Heritage-Study-Guide.doc
Contents: The Spanish Armada was a...
Name: Physical_Science_100.ppt
Contents: Slides for Physical Science Presentation...
--------------Your Friend's List--------------
--------------------------------------------


Enter option: 
3
Enter the index of your document you want to share: 
2

Enter option: 
4
-------------------Your List------------------
Name: MainLab1.cpp
Contents: #include <iostream> ....
Name: REL_A_131_Paper.doc
Contents: In the Book of Mormon, one of the main...
Name: American-Heritage-Study-Guide.doc
Contents: The Spanish Armada was a...
Name: Physical_Science_100.ppt
Contents: Slides for Physical Science Presentation...
--------------Your Friend's List--------------
Name: American-Heritage-Study-Guide.doc
Contents: The Spanish Armada was a...
--------------------------------------------


Enter option: 
2
Enter the index of your document you want to rename: 
2
Enter the updated name of the document: 
American-Heritage-Final-Study-Guide

Enter option: 
4
-------------------Your List------------------
Name: MainLab1.cpp
Contents: #include <iostream> ....
Name: REL_A_131_Paper.doc
Contents: In the Book of Mormon, one of the main...
Name: American-Heritage-Final-Study-Guide.doc
Contents: The Spanish Armada was a...
Name: Physical_Science_100.ppt
Contents: Slides for Physical Science Presentation...
--------------Your Friend's List--------------
Name: American-Heritage-Final-Study-Guide.doc
Contents: The Spanish Armada was a...
--------------------------------------------


Enter option: 
5

#include <iostream>
#include <string>
#include <vector>

using namespace std;

//Document.h
class Document{
private:
string name;
string extension;
string contents;
public:
Document(string nameIn, string extensionIn, string contentsIn);
string GetName();
void Rename(string newDocumentName);
string GetExtension();
string GetContents();
void Print();

};

//Document.cpp
Document::Document(string nameIn, string extensionIn, string contentsIn){
name = nameIn;
extension = extensionIn;
contents = contentsIn;
}
string Document::GetName(){
return name;
}
void Document::Rename(string newDocumentName){
name = newDocumentName;
}
string Document::GetExtension(){
return extension;
}
string Document::GetContents(){
return contents;
}
void Document::Print(){
cout << "Name: " << name << "." << extension << endl;
cout << "Contents: " << contents << endl;
}

//main.cpp----------
void DisplayMenu(){
cout << "Choose an option below: "<< endl;
cout << "1. Add a document to your list"<< endl;
cout << "2. Rename one of your documents"<< endl;
cout << "3. Share one of your documents with your friend"<< endl;
cout << "4. Display all of the documents"<< endl;
cout << "5. Quit"<< endl << endl;
}

int main(){
const int ADD_DOCUMENT_OPTION = 1;
const int RENAME_DOCUMENT_OPTION = 2;
const int SHARE_YOUR_DOCUMENT_OPTION = 3;
const int DISPLAY_ALL_DOCUMENTS_OPTION = 4;
const int QUIT_OPTION = 5;

int option;
DisplayMenu();
cin >> option;

while(option != QUIT_OPTION){
  
if(option == ADD_DOCUMENT_OPTION){

}
else if(option == RENAME_DOCUMENT_OPTION){

}
else if(option == SHARE_YOUR_DOCUMENT_OPTION){

}
else if(option == DISPLAY_ALL_DOCUMENTS_OPTION){

}
  
cout << endl << "Enter option: " << endl;
cin >> option;
}
return 0;
}
c++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// Document.h

#include <iostream>

using namespace std;

class Document{

private:

string name;

string extension;

string contents;

public:

Document(string nameIn, string extensionIn, string contentsIn);

string GetName();

void Rename(string newDocumentName);

string GetExtension();

string GetContents();

void Print();

};

//end of Document.h

// Document.cpp

#include "Document.h"

Document::Document(string nameIn, string extensionIn, string contentsIn){

name = nameIn;

extension = extensionIn;

contents = contentsIn;

}

string Document::GetName(){

return name;

}

void Document::Rename(string newDocumentName){

name = newDocumentName;

}

string Document::GetExtension(){

return extension;

}

string Document::GetContents(){

return contents;

}

void Document::Print(){

cout << "Name: " << name << "." << extension << endl;

cout << "Contents: " << contents << endl;

}

//end of Document.cpp

//main.cpp

#include <iostream>

#include <string>

#include <vector>

#include "Document.h"

using namespace std;

void DisplayMenu(){

       cout << "Choose an option below: "<< endl;

       cout << "1. Add a document to your list"<< endl;

       cout << "2. Rename one of your documents"<< endl;

       cout << "3. Share one of your documents with your friend"<< endl;

       cout << "4. Display all of the documents"<< endl;

       cout << "5. Quit"<< endl << endl;

}

int main() {

       const int ADD_DOCUMENT_OPTION = 1;

       const int RENAME_DOCUMENT_OPTION = 2;

       const int SHARE_YOUR_DOCUMENT_OPTION = 3;

       const int DISPLAY_ALL_DOCUMENTS_OPTION = 4;

       const int QUIT_OPTION = 5;

       vector<Document*> userList; // list of user documents

       vector<Document*> shareList; // list of shared documents

       int option;

       string name, ext, contents;

       int index;

       unsigned int i;

       DisplayMenu();

       cin >> option;

       while(option != QUIT_OPTION){

             if(option == ADD_DOCUMENT_OPTION) // add document to user list

             {

                    cout<<"Enter the document name: "<<endl;

                    cin>>name;

                    cout<<"Enter the document extension: "<<endl;

                    cin>>ext;

                    cin.ignore(100,'\n'); // ignore '\n' left by cin

                    cout<<"Enter the document content: "<<endl;

                    getline(cin,contents);

                    userList.push_back(new Document(name,ext,contents));

             }

             else if(option == RENAME_DOCUMENT_OPTION) // rename a document

             {

                    cout<<"Enter the index of your document you want to rename: "<<endl;

                    cin>>index;

                    cout<<"Enter the updated name of the document: "<<endl;

                    cin>>name;

                    if(index >= 0 && index < userList.size())

                           userList[index]->Rename(name);

             }

             else if(option == SHARE_YOUR_DOCUMENT_OPTION) // add document to shared list

             {

                    cout<<"Enter the index of your document you want to share: "<<endl;

                    cin>>index;

                    if(index >= 0 && index < userList.size())

                           shareList.push_back(userList[index]);

             }

             else if(option == DISPLAY_ALL_DOCUMENTS_OPTION) // display all documents

             {

                    cout<<"\n-------------------Your List------------------"<<endl;

                    if(userList.size() > 0)

                    {

                           for( i=0;i<userList.size();i++)

                                 userList[i]->Print();

                    }

                    cout<<"--------------Your Friend's List--------------"<<endl;

                    if(shareList.size() > 0)

                    {

                           for( i=0;i<shareList.size();i++)

                                 shareList[i]->Print();

                    }

                    cout<<"--------------------------------------------"<<endl;

             }

             cout << endl << "Enter option: " << endl;

             cin >> option;

       }

       // release the memory allocated to the documents

       if(userList.size() > 0)

       {

             for( i=0;i<userList.size();i++)

                    delete userList[i];

       }

       return 0;

}

//end of main.cpp

Output:

Choose an option below: 1. Add a document to your list 2. Rename one of your documents 3. Share one of your documents with yo

Enter option: Enter the document name: Physical Science 100 Enter the document extension: ppt Enter the document content: Sli

-----------Your List---------- Name: MainLab1.cpp Contents: #include <iostream> .... Name: REL_A_131_Paper.doc Contents: In t

Add a comment
Know the answer?
Add Answer to:
13.13 Final - Problem 2 (Chapter 8) Google Docs (20 points) Given the Document class below,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (Coding done in c++, Virtual Studio) Having a problem with the line trying to compare the...

    (Coding done in c++, Virtual Studio) Having a problem with the line trying to compare the date of birth.            **fall.sort(compare_DOB); //Here lies your error** #include <fstream> #include <iostream> #include <string> #include <list> #include <cctype> using namespace std; const char THIS_TERM[] = "fall.txt"; const string HEADER = "\nWhat do you want to do ?\n\n" "\t. Add a new friend name and DOB ? \n" "\t. Edit/Erase a friend record ? \n" "\t. Sort a Friend's record ? \n"...

  • Q) Modify the class Linked List below to make it a Doubly Linked List. Name your...

    Q) Modify the class Linked List below to make it a Doubly Linked List. Name your class DoublyLinkedList. Add a method addEnd to add an integer at the end of the list and a method displayInReverse to print the list backwards. void addEnd(int x): create this method to add x to the end of the list. void displayInReverse(): create this method to display the list elements from the last item to the first one. Create a main() function to test...

  • C++ Assignment on Search and Sort for Chapter 8 Problem: Modify the student grade problem to...

    C++ Assignment on Search and Sort for Chapter 8 Problem: Modify the student grade problem to include the following: •   Write a Search function to search by student score •   Write a Search function to search by student last name •   Write a Sort function to sort the list by student score •   Write a Sort function to sort the list by student last name •   Write a menu function that lets user to choose any action he/she want to...

  • In notepad 4. Build a document containing the following: a. Place a heading at the top...

    In notepad 4. Build a document containing the following: a. Place a heading at the top center of the document in all capital letters containing: MY BACKGROUND b. In a paragraph containing complete sentences of correctly spelled words, please describe the following about yourself: (1) Where you were born (city, state, country) (2) What brought you to Middlesex County College (3) What you are studying at Middlesex County College (4) What you like to do in your spare time when...

  • This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to...

    This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to create a Car class and Police Officer class, to create a new simulation. Write a simulation program (refer to the Bank Teller example listed below) that simulates cars entering a parking lot, paying for parking, and leaving the parking lot. The officer will randomly appear to survey the cars in the lot to ensure that no cars are parked...

  • C++ Design a class bankAccount that defines a bank account as an ADT and implements the...

    C++ Design a class bankAccount that defines a bank account as an ADT and implements the basic properties of a bank account. The program will be an interactive, menu-driven program. a. Each object of the class bankAccount will hold the following information about an account: account holder’s name account number balance interest rate The data members MUST be private. Create an array of the bankAccount class that can hold up to 20 class objects. b. Include the member functions to...

  • Godzilla Class Pt. 2 C++ I have to continue building off of this class and do...

    Godzilla Class Pt. 2 C++ I have to continue building off of this class and do the following I got help with the code below but could use some guidance as to how to finish this out. Any help would be appreciated This is the code for the main.cpp #include <iostream> #include "Godzilla.h" using namespace std; int main() { double health; double power; //prompt the user to input the health and power for Godzilla cout<< "Enter the health: " ;...

  • CSCI 2010 Lab11 Link-Lists Lab 11A Linked-Lists Preparation Create a Visual Studio C++ Project C...

    CSCI 2010 Lab11 Link-Lists Lab 11A Linked-Lists Preparation Create a Visual Studio C++ Project C2010Lab11A Add the following to the project. //LinkedList.cpp #include <cstdlib> #include "LinkedList.h" using namespace std; //--------------------------------------------------- //List Element Members //--------------------------------------------------- ListElement::ListElement(int d, ListElement * n) {    datum=d;    next=n; } int ListElement::getDatum () const {    return datum; } ListElement const* ListElement::getNext () const {    return next; } //--------------------------------------------------- //LinkedList Members //--------------------------------------------------- LinkedList::LinkedList () {    head=NULL; } void LinkedList::insertItem(int item) {    ListElement *currPtr = head;    ListElement *prevPtr =...

  • I've posted 3 classes after the instruction that were given at start You will implement and...

    I've posted 3 classes after the instruction that were given at start You will implement and test a PriorityQueue class, where the items of the priority queue are stored on a linked list. The material from Ch1 ~ 8 of the textbook can help you tremendously. You can get a lot of good information about implementing this assignment from chapter 8. There are couple notes about this assignment. 1. Using structure Node with a pointer point to Node structure to...

  • The purpose of this assignment is to develop solutions that perform File IO and objects. Problem specifications are shown below with my changes in blue. 1. File Previewer Write a program that asks...

    The purpose of this assignment is to develop solutions that perform File IO and objects. Problem specifications are shown below with my changes in blue. 1. File Previewer Write a program that asks the user for the name of a text file. The program should display the first 10 lines of the file on the screen. If the file has fewer than 10 lines, the entire file should be displayed along with a message indicating the entire file has been...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT