Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

WelcomeLetter.h #pragma once #include Observer.h #include Customer.h class WelcomeLetter : public Observer { public: WelcomeLetter ( void ) ; void update ( Customer

WelcomeLetter.h
#pragma once
#include "Observer.h"
#include "Customer.h"
class WelcomeLetter : public Observer
{
public:
WelcomeLetter(void);
void update( Customer *myCust);
public:
~WelcomeLetter(void);
};AddrVerification.cc
include "AddrVerification.h"
#include
using namespace std;
AddrVerification::AddrVerification(void)
{
}
AddrVerification::~AddrVerification(void)
{
}
void AddrVerification::update ( Customer *myCust)
{
// do Address verification stuff here
// can get more information about customer
// in question by using myCust
cout<<"in AddrVerification update"<
using namespace std;
Customer::Customer(void)
{
}
Customer::~Customer(void)
{
}
void Customer::attach( Observer *myObserver)
{
myObs.push_back( myObserver);
}
void Customer::detach( Observer *myObserver)
{
for (int i=0; i< myObs.size(); i++)
{
if (myObs[i]== myObserver)
{
myObs.erase(myObs.begin()+i);
return;
}
}
}
void Customer::notifyObs()
{
// set arg to something that helps
// tell the Observers what happened
for (int i=0; i< myObs.size(); i++)
{
myObs[i]->update(this);
}
}
string* Customer::getState()
{
string *state= new string;
// set state
return 0l;
}
Customer.h
#pragma once
#include
#include
#include
#include "Observer.h"
using namespace std;
class Customer
{
public:
Customer(void);
void attach( Observer *myObserver);
void detach( Observer *myObserver);
string* getState();
void notifyObs();
private:
vector myObs;
public:
~Customer(void);
};
CustomerTest.cc
#include "Observer.h"
#include "Customer.h"
#include "AddrVerification.h"
#include "WelcomeLetter.h"
#include
int main()
{
Customer *customer = new Customer();
WelcomeLetter *wl = new WelcomeLetter();
AddrVerification *av = new AddrVerification();
customer->attach(wl);
customer->attach(av);
customer->notifyObs();
cin.get();
}
Observer.cc
#include "Observer.h"
Observer::Observer(void)
{
}
Observer::~Observer(void)
{
}
Observer.h
#pragma once
class Customer;
class Observer
{
public:
Observer(void);
virtual void update( Customer *myCust)=0;
public:
~Observer(void);
};
WelcomeLetter.cc
#include "WelcomeLetter.h"
#include
using namespace std;
WelcomeLetter::WelcomeLetter(void)
{
}
WelcomeLetter::~WelcomeLetter(void)
{
}
void WelcomeLetter::update( Customer *myCust)
{
// do Welcome Letter stuff
// here can get more
// information about customer
// in question by using myCust
cout<<"in welcome letter update"< endl WelcomeLetter.h
#pragma once
#include "Observer.h"
#include "Customer.h"
class WelcomeLetter : public Observer
{
public:
WelcomeLetter(void);
void update( Customer *myCust);
public:
~WelcomeLetter(void);
};

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

3rd Edition

0760049041, 978-0760049044

More Books

Students also viewed these Databases questions