I need some idea for the Design of the following Program/Function.
My Program calculates Prices for Tools.
Every Tool has a Diameter and a List of Productionsteps to build this tool.
To get the Production Steps the program reads a XML File with 56 Productionsteps at the begin and creates an object for every Step. After the Creation it adds that object in a List.
The Konstruktor of the Tool knows what Steps are required to build the tool and get them out of the List of the Main Program and adds them to the List of the Tool.
Pseudo Code:
main.cs
List<ProductionStep> listOfAllProductionstep = readAllPS(../pfad/);
Tool abc = new Tool();
tool.cs
private List<ProductionStep> psList;
public Tool() {
foreach (ProductionStep ps in listOfAllProductionstep) {
switch(ps.Name) {
case "Abc":
psList.Add(ps);
break;
...
}
}
}
The Problem is now, each of the 56 Productionstep has it own formular to calculate the cost for this step. My first idea was to use a Switch Case construct in the calculatePrice Function of the tool. But i have to check every step with the 56 availiable Steps to get the Right Formular for this step. Now my Question. Is there a better solution to this?