Well I guess the only way to show you this is to post a huge chunk of my prog.....
This is my Controlle Class...
Code:
#include "CdInfo.h"
#include "Controller.h"
#include "Artist.h"
#include "Menu.h"
#include "SubMenu.h"
#include <iostream>
#include <string>
using namespace std;
//*********************MAIN*CONTROL********************
//Takes input from user and processes it
void Controller::CommandControl(int input){
Menu menu;
Artist artist;
if (input == 1)
{
menu.Info(); //Displays info about program
}
else if (input == 2)
{
CdInfoMenu();
}
else if (input == 3)
{
cout << "Goodbye" << endl; //End Program
}
else if (input == 4)
{
DisplayArtistList();
}
else
{
cout << input << ": is not a valid command" << endl;
}
}
//*******************CD*INFO**********************
//Takes input from user (CdInfo) and processes it
void Controller::CdInfoMenu(){
int input;
Menu menu;
Artist artist;
SubMenu submenu;
submenu.CdInfo();
cout << endl << "Enter your choose from the Cd Info Menu now:" << flush ;
cin >> input;
cout << endl;
if (input == 1)
{
artist.AddCdName();
myArtist.push_back(artist);
}
else if (input == 2)
{
DisplayArtistList();
}
else if (input == 3)
{
artist.FindCd();
}
else if (input == 4)
{
menu.MainMenu();
}
else
{
cout << input << ": is not a valid command" << endl;
}
}
//********************ARTIST**********************
//Adds Artist Name
void Controller::AddArtBandName() {
string artName;
cout << endl << "Enter the bands name: " << flush;
cin >> artName;
myArtist.push_back(Artist(artName));
cout << "\tAdded : " << artName << endl << endl ;
}
//Displays Artist List
void Controller::DisplayArtistList(){
cout << endl << "List of Artist: " << endl;
list<Artist>::iterator iter;
for(iter = myArtist.begin(); iter != myArtist.end(); iter++)
{
cout << (*iter).getArtBandName()<< endl;
(*iter).DisplayCdList();
}
}
//Not yet working
void Controller::FindCd()
{
string find;
cout <<"\tEnter name of Artist you want to find " << endl;
cout <<"\t WARNING " << endl;
cout <<"\t THIS SEARCH IS CASE SENSITIVE " << endl;
cout <<"Enter name of Artist now : " << flush;
cin >> find;
list<Artist>::iterator iter ;
for(iter = myArtist.begin(); iter != myArtist.end(); iter++)
{
if ((*iter).getArtBandName() == find)
{
cout << endl << "You have just found : " << (*iter).getArtBandName() << endl;
}
}
}
Controller::Controller(){
}
This is my Artist class
Code:
#include "Artist.h"
#include "Controller.h"
#include <iostream>
#include <string>
#include "Controller.h"
// Constructor
Artist::Artist(string lv_artName)
{
artName = lv_artName;
}
//Default Constructor
Artist::Artist(void)
{
}
//Holds artName
void Artist::setArtBandName(string lv_artName)
{
artName = lv_artName;
}
string Artist::getArtBandName()
{
return artName;
}
//Adds Cd Name
void Artist::AddCdName(){
string cdName;
cout << "Enter Cd's Name:" << flush;
cin >> cdName;
myCdInfo.push_back(CdInfo(cdName));
cout << "\tAdded : " << cdName << endl << endl;
OptionArtistInfo();
}
//Display Cd List
void Artist::DisplayCdList(){
cout << endl << "Cd List:" << endl;
list<CdInfo>::iterator iter;
for(iter = myCdInfo.begin(); iter != myCdInfo.end(); iter++)
{
cout << (*iter).getCdName();
}
}
void Artist::OptionArtistInfo(){
int input;
//A do while loop might be needed
cout << "Would you like to add Artist info for the cd : " << endl;
cout << "\tType 1 for yes or 2 for no : " << flush;
cin >> input;
switch (input)
{
case 1:
cout << endl << "Enter the bands name: " << flush;
cin >> artName;
break;
case 2:
cout << "Returning to main menu" << endl;
break;
default:
cout << input << " : Is not a valid command" << endl;
cout << " 1 and 2 are valid commands " << endl;
}
}
void Artist::FindCd(string find){
string find;
cout <<"\tEnter name of CD you want to find " << endl;
cout <<"\t WARNING " << endl;
cout <<"\t THIS SEARCH IS CASE SENSITIVE " << endl;
cout <<"Enter name of CD now : " << flush;
cin >> find;
list<CdInfo>::iterator iter ;
for(iter = myCdInfo.begin(); iter != myCdInfo.end(); iter++)
{
if ((*iter).getCdName() == find)
{
cout << endl << "You have just found : " << (*iter).getCdName() << endl;
}
}
}