代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
MSSQL
】
职责链模式
作者:
ling1510
/ 发布于
2014/4/11
/
1089
职责链模式实例
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Chain_of_Responsibility_Use { class PurchaseReuest { private int number; private double amount; private string purpose; public PurchaseReuest(int number, double amount, string purpose) { this.amount = amount; this.number = number; this.purpose = purpose; } public int Number { get { return number; } set { number = value; } } public double Amount { get { return amount; } set { amount = value; } } public string Purpose { get { return purpose; } set { purpose = value; } } } abstract class Approver { protected string name; protected Approver successor; public Approver(string name) { this.name = name; } public void setSuccessor(Approver successor) { this.successor = successor; } abstract public void ProcessRequest(PurchaseReuest request); } //ConcreteHandler class Director : Approver { public Director(string name) : base(name) { } public override void ProcessRequest(PurchaseReuest request) { //throw new NotImplementedException(); if (request.Amount < 10000.0) Console.WriteLine("{0} {1} approved request# {2} ", this, name, request.Number); else if (successor != null) successor.ProcessRequest(request); } } //ConcreteHandler class VicePresident : Approver { public VicePresident(string name) : base(name) { } public override void ProcessRequest(PurchaseReuest request) { //throw new NotImplementedException(); if (request.Amount < 25000.0) Console.WriteLine("{0} {1} approved request# {2} ", this, name, request.Number); else if (successor != null) successor.ProcessRequest(request); } } //ConcreteHandler class President : Approver { public President(string name) : base(name) { } public override void ProcessRequest(PurchaseReuest request) { //throw new NotImplementedException(); if (request.Amount < 100000.0) Console.WriteLine("{0} {1} approved request# {2} ", this, name, request.Number); else Console.WriteLine("Request# {0} request " + "an executie meeting ! ", request.Number); } } class Program { static void Main(string[] args) { Director Larry = new Director("Larry"); VicePresident Sam = new VicePresident("Sam"); President Tammy = new President("Tammy"); Larry.setSuccessor(Sam); Sam.setSuccessor(Tammy); PurchaseReuest rs = new PurchaseReuest(2034, 350.00, "Supplies"); Larry.ProcessRequest(rs); PurchaseReuest rx = new PurchaseReuest(2035, 12590.10, "Project X"); Larry.ProcessRequest(rx); PurchaseReuest ry = new PurchaseReuest(2036, 122100.00, "Project Y"); Larry.ProcessRequest(ry); Console.ReadKey(); } } }
试试其它关键字
职责链
同语言下
.
SQL查询 多列合并成一行用逗号隔开
.
查看存储过程修改时间,最近执行时间
.
设置手动批量删除数据库相关进程
.
获取某个表中特定字段的所有字符串形式
.
SQL 如何去除重复的字符串
.
怎么去掉一个字段中的重复数据
.
String 去除空格 回车 换行 水平制表符
.
SQL查询和替换含有回车,空格,TAB
.
SQL SERVER 查询每日新增用户数量、次留数量
.
判断两个字符串是否存在相同的内容
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
ling1510
贡献的其它代码
(
3
)
.
职责链模式
.
列出完数
.
对称三位数素数
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3