个人开发流程——计应191(西)第七组张曼曼
作业需求:编写四则运算。
程序:
namespace 计算器
{
public List<string> InorderToPostorder(Queue<string> q)
{
List<string> posterOrder = new List<string>();
Stack<string> inOrder = new Stack<string>();
inOrder.Push("#");
int count = q.Count;
for (int i = 0; i < count;i++ )
{
string item = q.Dequeue();
if (isOperateors(item))
{
string m = inOrder.First();
int n = Priority.isPriority(Priority.dicOperators[inOrder.First()],
Priority.dicOperators[item]);
while (n == 1)
{
string temp = inOrder.Pop();
if (temp != "(" && temp != ")")
{
posterOrder.Add(temp);
}
n = Priority.isPriority(Priority.dicOperators[inOrder.First()],
Priority.dicOperators[item]);
}
if (n == 2)
{
inOrder.Pop();
}
else if (n != -1)
{
inOrder.Push(item);
}
else
{
return null;
}
}
else
{
posterOrder.Add(item);
}
}
return inOrder.Count == 0 ? posterOrder : null;
}
public bool IsResult(List<string> PostorderExpress, out decimal result)
{
if (PostorderExpress != null)
{
try
{
PostorderExpress.Add("#");
string[] tempArry = PostorderExpress.ToArray();
int length = tempArry.Length;
int i = 0;
while (tempArry[i] != "#")
{
if (isOperateors(tempArry[i]))
{
tempArry[i - 2] = Arithmetic(tempArry[i - 2], tempArry[i - 1], tempArry[i]);
for (int j = i; j < length; j++)
{
if (j + 1 < length)
tempArry[j - 1] = tempArry[j + 1];
}
length -= 2;
i -= 2;
}
i++;
}
result = decimal.Parse(tempArry[0]);
return true;
}
catch (Exception e)
{
result = 0;
return false;
}
}
else
{
result = 0;
return false;
}
}
public string Arithmetic(string x,string y,string operators)
{
decimal a = decimal.Parse(x);
decimal b = decimal.Parse(y);
decimal result = 0;
switch (operators)
{
case "+":
result = a + b;
break;
case "-":
result = a - b;
break;
case "*":
result = a * b;
break;
case "/":
result = a / b;
break;
}
return result.ToString();
}
}
PSP
任务内容 | 计划共完成需要的时间(h) | 实际完成需要的时间(h) |
---|---|---|
计划 | 12 | 14 |
开发 | 10.5 | 11.5 |
需求分析 (包括学习新技术) | 0.5 | 1 |
· 生成设计文档 | 1 | 2 |
· 设计复审 (和同事审核设计文档) | 1 | 2 |
代码规范 (为目前的开发制定合适的规范) | 1 | 1.5 |
具体设计 | 1 | 1 |
具体编码 | 2 | 4 |
· 代码复审 | 1 | 1.5 |
· 测试(自我测试,修改代码,提交修改) | 1 | 1.5 |
报告 | 2 | 3 |
· 测试报告 | 1 | 2 |
计算工作量 | 1 | 2 |
· 事后总结 ,并提出过程改进计划 | 1 | 1 |
个人总结:
从上面的计划与实现表格也能看出来,实际上我的开发时间是预估时间的两倍之久。并且投入在设计上的时间非常之长(需求分析+生成设计文档+设计复审+具体设计)。本次个人项目中学到最多的不是关于C#的语法说明,更不是一些算法的应用技巧,我觉得收获最多的是关于想与做的协调的认识。在编程早期我很喜欢看题之后提笔就写,之后经历了计组实验,发现了提前设计的必要性与反思的收获。再之后就是在面向对象课程的训练之下,对于细节的注意和关于出错小心翼翼的处理。