static void Main(string[] args) { Sales[] sales = new Sales[3]; sales[0] = new Sales('A', "Andrea"); sales[1] = new Sales('B', "Brittany"); sales[2] = new Sales('E', "Eric"); Sales.promptSales(sales); //print out each employee commission Sales.printSales(sales); pause(); }
public static void promptSales(Sales[] sales) { char input; bool firstRun = true; while ( (input = Input.promptChar( firstRun ? "Enter a salesperson initial: " : "Enter next salesperson or Z to quit: ", "Please enter a valid salesperson initial... ", Sales.getOptions()) ) != 'z' && input != 'Z' ) { //match input to a sales person foreach (Sales sale in sales) { if (char.ToUpper(sale.getCharCode()) == char.ToUpper(input)) { //input sales amount sale.accumSaleAmt( Input.promptDouble("Enter amount of sale: ", "Please enter a valid currency value... ") ); } }//end inner loop firstRun = false; }//end loop }
public static void printSales(Sales[] sales) { foreach (Sales sale in sales) { Console.WriteLine(sale.ToString()); }//end loop }