static void outputAggregateData(AggregateDataDollarWords aggregateData) { Console.WriteLine(aggregateData.ToString()); Console.Write("Enter x for exact dollar words, or d for dollar words, nothing to end: "); int input = Console.Read(); switch (input) { case 'x': foreach (string word in aggregateData.getDollarWords()) { Console.WriteLine(word); } break; case 'd': foreach (string word in aggregateData.getExactDollarWords()) { Console.WriteLine(word); } break; default: break; } }
static void saveExactDollarWords(AggregateDataDollarWords aggregateData) { using (TextWriter tw = new StreamWriter("exactDollarWords.txt")) foreach (string word in aggregateData.getExactDollarWords()) { tw.WriteLine(word); } }
static void Main() { AggregateDataDollarWords aggregateData = openFileAndCalculateDollarWords(path); outputAggregateData(aggregateData); saveDollarWords(aggregateData); saveExactDollarWords(aggregateData); //Keep console open Console.Read(); }
private static AggregateDataDollarWords calculateDollarWords(StreamReader reader) { AggregateDataDollarWords aggregateData = new AggregateDataDollarWords(); string word; int cents; aggregateData.startTimer(); while ((word = reader.ReadLine()) != null) { cents = calculateCost(word); if (cents >= 100) { aggregateData.addDollarWord(word, cents); } } aggregateData.endTimer(); return(aggregateData); }