static void Main(string[] args) { try { string inputPath = "../../input.txt"; string inputText = File.ReadAllText(inputPath); string[] inputLines = inputText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); Console.WriteLine(inputText); Console.WriteLine(); AliasMapper aliasMap = new AliasMapper(); IDecimalConverter converter = new RomanConverter(); MetalMapper metalMap = new MetalMapper(); ExpressionParser parser = new ExpressionParser(aliasMap, converter, metalMap); foreach (string line in inputLines) { parser.Parse(line); } Console.ReadLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main(string[] args) { Console.WriteLine("--- ROMAN TO DECIMAL CONVERTER --- "); Console.WriteLine(); string path = AppDomain.CurrentDomain.BaseDirectory + "input.txt"; // Open the file to read from. string readText = File.ReadAllText(path); string[] lines = readText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); Console.WriteLine("--- Input Start ---"); Console.WriteLine(readText); Console.WriteLine("--- Input End ---"); Console.WriteLine(); Console.WriteLine("--- Output Start ---"); #region "Initialize required components for the convertions" AliasMapper aliasMap = new AliasMapper(); IDecimalConverter converter = new RomanConverter(); CommodityIndex commodityIndex = new CommodityIndex(); #endregion ExpressionParser parser = new ExpressionParser(aliasMap, converter, commodityIndex); foreach (string line in lines) { parser.Parse(line); } Console.WriteLine("--- Output End ---"); Console.ReadLine(); }
public UnitExpression(AliasMapper aliasMap, MetalMapper metalMap, IDecimalConverter converter, ExpressionValidationHelper helper) { _aliasMap = aliasMap; _metalMap = metalMap; _converter = converter; _helper = helper; }
public CommodityConversionExpression(CommodityIndex commodityIndex, AliasMapper aliasMap, IDecimalConverter converter, ExpressionValidationHelper helper) { this.commodityIndex = commodityIndex; this.aliasMap = aliasMap; this.converter = converter; this.helper = helper; }
public void AliasExpressionTest() { AliasMapper aliasMap = new AliasMapper(); AliasExpressionType expression = new AliasExpressionType(aliasMap); Assert.True(expression.Match("glob is C")); Assert.False(expression.Match("glob is N")); expression.Execute("glob is C"); Assert.True(aliasMap.Exists("glob")); Assert.Equal("C", aliasMap.GetValueForAlias("glob")); }
public void AliasExpressionTest() { AliasMapper aliasMap = new AliasMapper(); AliasExpression expression = new AliasExpression(aliasMap); Assert.IsTrue(expression.Match("glob is C")); Assert.IsFalse(expression.Match("glob is N")); expression.Execute("glob is C"); Assert.IsTrue(aliasMap.Exists("glob")); Assert.IsTrue(String.Equals(aliasMap.GetValueForAlias("glob"), "C")); }
public static List <IExpression> GetExpressions(AliasMapper aliasMap, IDecimalConverter converter, CommodityIndex commodityIndex, ExpressionValidationHelper helper) { List <IExpression> expressions = new List <IExpression>(); expressions.Add(new AliasExpression(aliasMap)); expressions.Add(new UnitExpression(commodityIndex, aliasMap, converter, helper)); expressions.Add(new AliasQuestionExpression(aliasMap, converter, helper)); expressions.Add(new UnitQuestionExpression(commodityIndex, aliasMap, converter, helper)); expressions.Add(new CommodityConversionExpression(commodityIndex, aliasMap, converter, helper)); return(expressions); }
private List <IExpression> GetExpressions(AliasMapper aliasMap, IDecimalConverter converter, MetalMapper metalMap, ExpressionValidationHelper helper) { List <IExpression> expressions = new List <IExpression>(); expressions.Add(new AliasExpression(aliasMap)); expressions.Add(new UnitExpression(aliasMap, metalMap, converter, helper)); expressions.Add(new AliasQuestionExpression(aliasMap, converter, helper)); expressions.Add(new UnitQuestionExpression(aliasMap, metalMap, converter, helper)); expressions.Add(new MetalExpression(aliasMap, metalMap, converter, helper)); return(expressions); }
public void UnitExpressionTest() { AliasMapper aliasMap = new AliasMapper(); RomanConverter converter = new RomanConverter(); MetalMapper metalMap = new MetalMapper(); aliasMap.AddAlias("glob", "I"); aliasMap.AddAlias("pish", "X"); ExpressionValidationHelper helper = new ExpressionValidationHelper(aliasMap, metalMap); UnitExpression expression = new UnitExpression(aliasMap, metalMap, converter, helper); expression.Execute("pish glob Iron is 110 Credits"); Assert.True(metalMap.Exists("Iron")); Assert.Equal <double>(10, metalMap.GetPriceByMetal("Iron")); expression.Execute("glob pish Iron is 6300 Credits"); Assert.Equal <double>(700, metalMap.GetPriceByMetal("Iron")); }
public void UnitExpressionTest() { AliasMapper aliasMap = new AliasMapper(); RomanConverter converter = new RomanConverter(); CommodityIndex commodityIndex = new CommodityIndex(); aliasMap.AddAlias("glob", "C"); aliasMap.AddAlias("pish", "X"); ExpressionValidationHelper helper = new ExpressionValidationHelper(aliasMap, commodityIndex); UnitExpression expression = new UnitExpression(commodityIndex, aliasMap, converter, helper); expression.Execute("pish glob Iron is 7020 Credits"); Assert.IsTrue(commodityIndex.Exists("Iron")); Assert.AreEqual <double>(commodityIndex.GetPriceByCommodity("Iron"), 78); expression.Execute("pish glob Iron is 6300 Credits"); Assert.AreEqual <double>(commodityIndex.GetPriceByCommodity("Iron"), 70); }
static void Main(string[] args) { Console.WriteLine(); string path = "../../input.txt"; string readText = File.ReadAllText(path); string[] lines = readText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); Console.WriteLine(readText); Console.WriteLine(); AliasMapper AliasMap = new AliasMapper(); IDecimalConverter converter = new RomanConverter(); MetalMapper metalMap = new MetalMapper(); ExpressionParser parser = new ExpressionParser(AliasMap, converter, metalMap); foreach (string line in lines) { parser.Parse(line); } Console.ReadLine(); }
public void UnitExpressionTest() { AliasMapper aliasMap = new AliasMapper(); RomanConverter converter = new RomanConverter(); CommodityIndex commodityIndex = new CommodityIndex(); aliasMap.AddAlias("glob", "I"); aliasMap.AddAlias("prok", "V"); aliasMap.AddAlias("pish", "X"); aliasMap.AddAlias("tegj", "L"); ExpressionValidationHelper helper = new ExpressionValidationHelper(aliasMap, commodityIndex); UnitExpression expression = new UnitExpression(commodityIndex, aliasMap, converter, helper); expression.Execute("glob glob silver is 34 Credits"); Assert.True(commodityIndex.Exists("silver")); Assert.Equal <double>(17, commodityIndex.GetPriceByCommodity("silver")); expression.Execute("glob prok iron is 400 Credits"); Assert.Equal <double>(100, commodityIndex.GetPriceByCommodity("iron")); }
static void Main(string[] args) { Console.WriteLine("--- ROMAN TO DECIMAL CONVERTER --- "); Console.WriteLine(); if (args == null || args.Length == 0) { Console.WriteLine("Please specify a filename as a parameter."); return; } string path = args[0]; // Open the file to read from. string readText = File.ReadAllText(path); string[] lines = readText.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); Console.WriteLine("--- Input Start ---"); Console.WriteLine(readText); Console.WriteLine("--- Input End ---"); Console.WriteLine(); Console.WriteLine("--- Output Start ---"); #region "Initialize required components for the convertions" AliasMapper aliasMap = new AliasMapper(); IDecimalConverter converter = new RomanConverter(); CommodityIndex commodityIndex = new CommodityIndex(); #endregion ExpressionParser parser = new ExpressionParser(aliasMap, converter, commodityIndex); foreach (string line in lines) { parser.Parse(line); } Console.WriteLine("--- Output End ---"); Console.ReadLine(); }
static void Main(string[] args) { try { // The code provided will print ‘Hello World’ to the console. // Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app. Console.WriteLine("--- Merchant Galaxy --- "); Console.WriteLine(); string path = "../../inputData.txt"; string readText = File.ReadAllText(path); string[] lines = readText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); Console.WriteLine("--- Input Start ---"); Console.WriteLine(readText); Console.WriteLine("--- Input End ---"); Console.WriteLine(); Console.WriteLine("--- Output Start ---"); #region "Initialize components for the conversions" AliasMapper aliasMap = new AliasMapper(); IDecimalConverter converter = new RomanConverter(); CommodityIndex commodityIndex = new CommodityIndex(); #endregion ExpressionParser parser = new ExpressionParser(aliasMap, converter, commodityIndex); foreach (string line in lines) { parser.Parse(line); } Console.WriteLine("--- Output End ---"); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine("Error:" + ex.Message); } }
public ExpressionValidationHelper(AliasMapper pseudonymMap, MetalMapper metalMap) { _pseudonymMap = pseudonymMap; _metalMap = metalMap; }
public ExpressionValidationHelper(AliasMapper aliasMap, CommodityIndex commodityIndex) { this.aliasMap = aliasMap; this.commodityIndex = commodityIndex; }
public AliasExpression(AliasMapper aliasMap) { this.aliasMap = aliasMap; }
public ExpressionValidationHelper(AliasMapper aliasMap, MetalMapper metalMap) { _aliasMap = aliasMap; _metalMap = metalMap; }
public EmailAddressMapper() { this.AliasMapper = new AliasMapper(); }
public AliasExpression(AliasMapper aliasMap) { _aliasMap = aliasMap; }
public ExpressionParser(AliasMapper aliasMap, IDecimalConverter converter, MetalMapper metalMap) { helper = new ExpressionValidationHelper(aliasMap, metalMap); expressions = GetExpressions(aliasMap, converter, metalMap, helper); }
public AliasQuestionExpression(AliasMapper aliasMap, IDecimalConverter converter, ExpressionValidationHelper helper) { _aliasMap = aliasMap; _converter = converter; _helper = helper; }
public AliasQuestionExpression(AliasMapper aliasMap, IDecimalConverter converter, ExpressionValidationHelper helper) { this.aliasMap = aliasMap; this.converter = converter; this.helper = helper; }
public ExpressionParser(AliasMapper aliasMap, IDecimalConverter converter, CommodityIndex commodityIndex) { helper = new ExpressionValidationHelper(aliasMap, commodityIndex); expressions = RomanToDecimalFactory.GetExpressions(aliasMap, converter, commodityIndex, helper); }