That helped tremendously! Thank you both. Now I just gotta figure out a few more things that are giving errors.
DVDcollection.h:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class DVD
{
private:
string title; //To hold title of movie
int year; //To hold year release
double length; //To hold length of movie
public:
vector<string> actor; //To hold actor and actress names
vector<string> charNames; //To hold name of character
//Default constructor setting everything to zero
DVD()
{
title = " ";
length = 0;
year = 0;
}
DVD(string t, double l, int y)
{
title = t;
length = l;
year = y;
}
// Mutator Functions
void setTitle(string t)
{
title;
}
void setLength(double l)
{
length;
}
void setYear(int y)
{
year;
}
string getTitle() const
{
return title;
}
double getLength() const
{
return length;
}
int getYear() const
{
return year;
}
void addActor(string actors, string charName)
{
actor.push_back(actors);
charNames.push_back(charName);
}
};
|
main.cpp:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
|
#include "DVDcollection.h"
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;
int main()
{
int choice; // To hold choice for the menu
int howMany; // To hold the number of actors to be entered
string title; // To hold the title of the DVD
int year; // To hold the year released
double length; // To hold the length of the movie
string actor; // To hold the name of the actor
string characterName; // To hold the character name
DVD myDVD; // DVD class
// Function Prototypes
void showList(string, double, int, string, string);
void removeDVD(string);
void updateDVD(string);
//Menu System
cout << "-----------------------------------------------------------------------------------------" << endl;
cout << " DVD Collection " << endl;
cout << "-----------------------------------------------------------------------------------------" << endl;
cout << endl << endl;
cout << "1. Add a DVD" << endl;
cout << "2. Remove a DVD" << endl;
cout << "3. Update a DVD" << endl;
cout << "4. Show List of DVDs" << endl;
cout << "5. Exit" << endl;
cin >> choice;
switch (choice)
{
case 1:
{
cout << "To add a new DVD - enter the title, length, year released, actors/actresses and their characters:" << endl;
cout << endl;
cout << "Movie Title: ";
getline(cin, title);
cout << endl;
cout << "Length: ";
cin >> length;
cout << endl;
cout << "Year: ";
cin >> year;
cout << endl;
cout << "You entered: " << title << " " << length << " " << year << endl;
cout << endl;
cout << "How many actors/characters do you want to add?" << endl;
cin >> howMany;
// Loop to allow entry of all actors desired
for (int count = 0; count < howMany; count++)
{
//Actor and Actress
cout << "Actor/Actress #" << (count + 1) << " Name: ";
getline(cin, actor);
cout << endl;
//Character they play
cout << "Character they play: ";
getline(cin, characterName);
}
//Store the dvd info
myDVD.setTitle(title);
myDVD.setYear(year);
myDVD.setLength(length);
myDVD.addActor(actor, characterName);
}break;
case 2:
{
void removeDVD();
break;
}
case 3:
{
void updateDVD();
break;
}
case 4:
{
void showList();
break;
}
case 5:
{
exit(0);
}
}
}
// ***
// Definition of function showList
// This function displays the list of DVDs that have been stored
// ***
void showList(vector<string> &vectorActor, vector<string>&vectorCharNames, DVD *myDVD)
{
// Formats the table for the output
cout << setw(10) << "\nMovie Title: "
<< setw(10) << "Length:"
<< setw(10) << "Year: "
<< setw(10) << "Actors/Actresses:"
<< setw(10) << "Characters:\n" << endl;
cout << "------------------------------------------------------------\n";
for (auto count = 0; count < vectorActor.size(); count++)
{
if (count < 1)
{
if (myDVD[count].getLength() != 0)
{
cout << endl << setw(10) << right << myDVD[count].getTitle()
<< setw(10) << myDVD[count].getLength()
<< setw(10) << myDVD[count].getYear();
}
else
{
cout << setw(10) << right << myDVD[count].getTitle();
}
}
else
{
if (myDVD[count].getLength() != 0)
{
cout << endl << setw(10) << right << myDVD[count].getTitle()
<< setw(10) << myDVD[count].getLength()
<< setw(10) << myDVD[count].getYear();
}
else
{
cout << setw(10) << right << myDVD[count].getTitle();
}
}
if (count < 1)
cout << "\t\t" << vectorActor[count]
<< " " << vectorCharNames[count] << endl;
else
{
cout << "\t\t\t\t" << vectorActor[count]
<< " " << vectorCharNames[count] << endl;
}
}
}
// ***
// Definition of function removeDVD
// This function removes one of the DVDs that have been stored
// ***
void RemoveDVD(string, class DVD &myDVD)
{
cout << "\nEnter the Movie Title you would like to remove: ";
string title = "";
cin.sync();
getline(cin, title);
map<string,DVD>::iterator result = myDVD.find(title);
if (result == myDVD.end())
{
cout << "\nNo records found. None were removed.";
return;
}
cout << "\nThis dvd was found:";
(*result).second.listDVDData(cout);
char confirm;
cout << "\nConfirm removal(y/n): ";
cin >> confirm;
if (tolower(confirm) == 'y')
{
myDVD.erase(result);
}
};
|
Errors:
1>------ Build started: Project: Week8ClassProject, Configuration: Debug Win32 ------
1> main.cpp
1>c:\users\x\documents\visual studio 2015\projects\week8classproject\week8classproject\main.cpp(145): warning C4018: '<': signed/unsigned mismatch
1>c:\users\x\documents\visual studio 2015\projects\week8classproject\week8classproject\main.cpp(199): error C2039: 'find': is not a member of 'DVD'
1> c:\users\x\documents\visual studio 2015\projects\week8classproject\week8classproject\dvdcollection.h(9): note: see declaration of 'DVD'
1>c:\users\x\documents\visual studio 2015\projects\week8classproject\week8classproject\main.cpp(201): error C2039: 'end': is not a member of 'DVD'
1> c:\users\x\documents\visual studio 2015\projects\week8classproject\week8classproject\dvdcollection.h(9): note: see declaration of 'DVD'
1>c:\users\x\documents\visual studio 2015\projects\week8classproject\week8classproject\main.cpp(208): error C2039: 'listDVDData': is not a member of 'DVD'
1> c:\users\x\documents\visual studio 2015\projects\week8classproject\week8classproject\dvdcollection.h(9): note: see declaration of 'DVD'
1>c:\users\x\documents\visual studio 2015\projects\week8classproject\week8classproject\main.cpp(216): error C2039: 'erase': is not a member of 'DVD'
1> c:\users\x\documents\visual studio 2015\projects\week8classproject\week8classproject\dvdcollection.h(9): note: see declaration of 'DVD'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========