商店管理系统的C#观察者模式 [英] C# observer pattern for store management system

查看:120
本文介绍了商店管理系统的C#观察者模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个单独的库项目,其中包含商店,产品,供应商,购物车类。



问题是..



如何在此项目中实现Observer模式以实现以下目标...



该程序应该能够在将任何产品添加到购物车时更新每个供应商帐户余额。商店还必须更新它的内容,即可用的产品或现在售罄的产品,而不是为客户展示。在购买尚未确认(已付款)时,购物车本身必须在添加或删除产品时更新其价值。该产品可能会受到价格变化的影响。



我做了以下指定:

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:

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

推荐答案

codeproject:observer pattern - Google Search [ ^ ]


似乎论坛是睡着了什么......
Seems the forum is asleep or something...


这篇关于商店管理系统的C#观察者模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆