评"软件工程项目管理:功能点分析方法与实践"
2008-01-05 11:39
1646 查看
using System.Collections;
using System.Collections.Generic;
namespace OOPM
...{
public class Interpret
...{
}
public class Context
...{
private string _Statement;
private int _Data;
public Context(string statement)
...{
this._Statement = statement;
}
public string Statement
...{
get
...{
return this._Statement;
}
set
...{
this._Statement = value;
}
}
public int Data
...{
get
...{
return this._Data;
}
set
...{
this._Data = value;
}
}
}
public abstract class Expression
...{
protected Dictionary<string, int> table = new Dictionary<string, int>(9);
public Expression()
...{
table.Add("一", 1);
table.Add("二", 2);
table.Add("三", 3);
table.Add("四", 4);
table.Add("五", 5);
table.Add("六", 6);
table.Add("七", 7);
table.Add("八", 8);
table.Add("九", 9);
}
public virtual void Interpret(Context context)
...{
if(context.Statement.Length == 0)
...{
return;
}
foreach (string key in table.Keys)
...{
int value = table[key];
if (context.Statement.EndsWith(key + GetPostfix()))
...{
context.Data += value * this.Multiplier();
context.Statement = context.Statement.Substring(0, context.Statement.Length-this.GetLength());
}
if (context.Statement.EndsWith("零"))
...{
context.Statement = context.Statement.Substring(0, context.Statement.Length - 1);
}
}
}
public abstract string GetPostfix();
public abstract int Multiplier();
public virtual int GetLength()
...{
return this.GetPostfix().Length + 1;
}
}
public class WanExpression : Expression
...{
public override string GetPostfix()
...{
return "万";
}
public override int Multiplier()
...{
return 10000;
}
public override void Interpret(Context context)
...{
if (context.Statement.Length == 0)
...{
return;
}
ArrayList tree = new ArrayList();
tree.Add(new GeExpression());
tree.Add(new ShiExpression());
tree.Add(new BaiExpression());
tree.Add(new QianExpression());
foreach (string key in table.Keys)
...{
if (context.Statement.EndsWith(GetPostfix()))
...{
int temp = context.Data;
context.Data = 0;
context.Statement = context.Statement.Substring(0, context.Statement.Length - 1);
foreach (Expression exp in tree)
...{
exp.Interpret(context);
}
context.Data = temp + this.Multiplier() * context.Data;
}
}
}
}
public class QianExpression : Expression
...{
public override string GetPostfix()
...{
return "千";
}
public override int Multiplier()
...{
return 1000;
}
}
public class BaiExpression : Expression
...{
public override string GetPostfix()
...{
return "百";
}
public override int Multiplier()
...{
return 100;
}
}
public class ShiExpression : Expression
...{
public override string GetPostfix()
...{
return "十";
}
public override int Multiplier()
...{
return 10;
}
}
public class GeExpression : Expression
...{
public override string GetPostfix()
...{
return "";
}
public override int Multiplier()
...{
return 1;//10^0
}
public override int GetLength()
...{
return 1;
}
}
/**//// <summary>
/// 客户代码
/// </summary>
public class InterpretApp
...{
public static int Main(string ChineseCharacter)
...{
Context context = new Context(ChineseCharacter);
ArrayList tree = new ArrayList();
tree.Add(new GeExpression());
tree.Add(new ShiExpression());
tree.Add(new BaiExpression());
tree.Add(new QianExpression());
tree.Add(new WanExpression());
foreach (Expression exp in tree)
...{
exp.Interpret(context);
}
return context.Data;
}
}
}
相关文章推荐
- 功能点分析方法在软件需求管理中的应用
- 【软件项目管理】用例分析方法采用一种面向对象的情景分析方法
- 软件项目量化管理(QPM)及根因分析实践总结(CMMI高成熟度访谈)
- 关于“功能点分析-成功软件项目的测量实践”
- 软件工程——理论、方法与实践 之 面相对象分析
- 数据库备份的四种方法 & 软件功能需求分析
- 项目管理理论与实践(2)——软件需求分析
- 结构化分析方法是一种自下而上逐步求精的分析方法【软件项目管理】
- 软件工程:理论、方法与实践 软件项目管理读后感
- 软件项目管理(CMMI成熟度)实践——之决策分析(2)
- 如何管理"吃力不讨好"的软件定制项目?
- 【SSH项目实战】国税协同平台-4.用户管理需求分析&CRUD方法2
- 软件项目管理(CMMI成熟度)实践——之决策分析(1)
- 【SSH项目实战】国税协同平台-4.用户管理需求分析&CRUD方法1
- 项目管理理论与实践(2)——软件需求分析
- 项目管理理论与实践(7)——软件开发报价的计算方法
- 【SSH项目实战】国税协同平台-4.用户管理需求分析&CRUD方法2
- 项目管理理论与实践(7)——软件开发报价的计算方法
- 【SSH项目实战】国税协同平台-4.用户管理需求分析&CRUD方法1
- Gradle 使用Jetty插件启动web项目时出现"java.lang.OutOfMemoryError: PermGen space"解决方法