Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Homework Help/Study Tips Expert

Assignment

Demonstrate the ability to create a program that utilizes the Observer design pattern. Demonstrate the ability to create abstract classes and implement derived classes. Demonstrate the ability to create and iterate over an STL list that contains callback functions. Assignment You will be creating a program that implements the Observer design pattern. This design pattern is utilized in almost all GUI systems and is the basis for distributed event handling. The goal of the program is to create a class (the Subject class for this assignment) that has a private variable (address) that can be modified via a standard mutator function (setAddress). This class has additional member functions that allow other classes (the observers) to register and deregister themselves with the Subject. If observers are registered with the subject, they will receive notifications (via a callback function) if the subject's address ever changes.

You are to create these observer classes BankObserver, SchoolObserver, CreditObserver. Each of the observers must be derived from this abstract base class: class AbstractObserver { public: virtual void subjectChanged(string)=0; virtual ~AbstractObserver(){} }; Each should override the subjectChanged method by printing the string argument to the screen along with the name of it's class. For instance, the BankObserver might print the following:

The BankObserver received an address change notification: <string> CS 1337.502,504 F16 Program #6 Page 1 of 2 You will then create one instance of the Subject class and one instance each of three derived observer classes. You will register the instances of the observer classes with the instance of the Subject class. When registered, you will make a change to the instance of the subject class (using the setAddress method). This change should cause each of the registered observers to receive a callback with notification of the change. The notify() method implements this functionality.

You must then deregister at least one of the observer instances and make a change to the subject instance. This will result in only the remaining registered observers receiving notification.

Here is the Class prototype for the Subject:

class Subject { private: string address; list<AbstractObserver *> observers; void notify(); public: Subject(string addr); void addObserver(AbstractObserver& observer); void removeObserver(AbstractObserver& observer); string getAddress(); void setAddress(string newAddress); }; Requirements Your code must extend and use the AbstractObserver class

Your code must implement the Subject class

Your code must exhibit the use of the Observer design pattern

Your code must exhibit the use of the STL list data type

Your code must exhibit the use of an STL list iterator

Your code must exhibit correct operation with registered callbacks

Your code must exhibit correct operation with deregistered callbacks Deliverables

You must submit your homework through ELearning. You must include your source files.

No late homework is accepted. Observer Pattern (http://en.wikipedia.org/wiki/Observer_pattern)

The observer pattern is a software design pattern in which an object, called the subject,

maintains a list of its dependents, called observers, and notifies them automatically of any state

changes, usually by calling one of their methods. It is mainly used to implement distributed event

handling systems. The Observer pattern is also a key part in the familiar Model View Controller

(MVC) architectural pattern. [1] In fact the observer pattern was first implemented in Smalltalk's

MVC based user interface framework.[2] The observer pattern is implemented in numerous programming libraries and systems, including almost all GUI toolkits.

Homework Help/Study Tips, Others

  • Category:- Homework Help/Study Tips
  • Reference No.:- M92057291
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Homework Help/Study Tips

Assignment detailsthe ideal police force is one that

Assignment Details The ideal police force is one that prevents crime, keeps order, respects the rights and dignity of citizens, is friendly and courteous, respects the laws, and does not abuse its power through corruptio ...

Question select one of the paraphilias or one of the eating

Question: Select one of the Paraphilias or one of the Eating Disorders. Use the Research Analysis to complete this assignment. Prepare a 1,200- to 1,700-word paper that discusses research-based interventions to treat the ...

Question this module discusses individual and

Question: This module discusses individual and family-related interventions. Discuss the role of individuals and families in changing health behaviors. Drawing from your own personal experiences, provide examples of how ...

This final conference deals with the final issue any

This final conference deals with the final issue any computer forensics examiner, or any other witness to an event will face - testifying under oath to what you know. Each person who testifies is a witness and as we disc ...

Essay assignment -write an essay in response to one of the

Essay Assignment - Write an essay in response to one of the topics below. Your essay should have at least 5 paragraphs, including Introduction and Conclusion. You must make specific reference to the reading upon which th ...

Question is resurrection a more plausible view of the after

Question: Is resurrection a more plausible view of the after life than reincarnation? Why or why not? [You should focus on whether your identity is better preserved in the physical body, or the mind.] Instructions: - Wri ...

What is the relationship between race socio-economic status

What is the relationship between race, socio-economic status and cruel and unusual punishment? Consider the history of the United States and the 8th Amendment in your response

Video chat should surgery be done to normalize intersexed

Video Chat: Should surgery be done to "normalize" intersexed babies' genitals? Or should parents wait until the child is old enough to make that decision for themselves? Why? There are many opportunities to respond to qu ...

Scientific research methods assignment -a key part of

Scientific Research Methods Assignment - A key part of research papers and theses is a well-supported description and validation of research methods. For this assessment you are required to choose a research topic and wr ...

Question write a five-paragraph essayif you stumble about

Question: Write a five-paragraph essay "If you stumble about believability, what are you living for? Love is hard to believe, ask any lover. Life is hard to believe, ask any scientist. God is hard to believe, ask any bel ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As