Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have made a separate library project that has the classes of Store, Product, Vendor, Cart.

And the question is..

How can I implement the Observer pattern in this project to achieve the following...

The program should be able to update each vendor account balance when any of his products is added to the cart. The store also must update it's contents , ie the products that are available or those that are now sold out and not show them for the customer. The cart itself must update it's value upon the addition or removal of products from it while the purchase is still not confirmed ( paid ). The product in turn may be a subject to a price change.

I made the following designations:
C#
public class Cart : ObservableCollection<Product> , IObservable<Product>
public class Store : ObservableCollection<Product>
public class Vendor : IObserver<Product>


And the product class is a standard class with product properties...

What I have tried:

No pattern implemented yet, i made a previous version that didn't follow any design pattern
Posted
Updated 3-Jan-18 12:47pm

 
Share this answer
 
Comments
Roberta Mafessoni 25-Dec-17 6:37am    
Hello Mr. Rude MacCheese
Thanks for the reply.
I've already seen much of the links you provided.
Richard MacCutchan 26-Dec-17 2:49am    
Good, then you know how to do it.
Seems the forum is asleep or something...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900