//Methods public virtual void DisplayComponents() { // These are used to get the #of components (gears, springs, levers) WidgetSmall SmallWidget = new WidgetSmall(); WidgetMedium MediumWidget = new WidgetMedium(); Console.ForegroundColor = ConsoleColor.White; Console.Write("Number of Small Widgets: "); Console.CursorLeft = 30; Console.WriteLine(this.NumberOfSmallWidgets); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine(" Composed of:"); Console.CursorLeft = 4; Console.Write("# of Gears....." + SmallWidget.NumOfGears + "\n"); Console.CursorLeft = 5; Console.Write("# of Springs.." + SmallWidget.NumOfSprings + "\n"); Console.CursorLeft = 6; Console.Write("# of Levers.." + SmallWidget.NumOfLevers + "\n"); Console.WriteLine(); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Console.Write("Number of Medium Widgets: "); Console.CursorLeft = 30; Console.WriteLine(this.NumberOfMediumWidgets); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine(); Console.WriteLine(" Composed of:"); Console.CursorLeft = 4; Console.Write("# of Gears....." + MediumWidget.NumOfGears + "\n"); Console.CursorLeft = 5; Console.Write("# of Springs.." + MediumWidget.NumOfSprings + "\n"); Console.CursorLeft = 6; Console.Write("# of Levers.." + MediumWidget.NumOfLevers + "\n"); Console.WriteLine(); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Console.Write("Number of Switches: "); Console.CursorLeft = 30; Console.WriteLine(this.NumberOfSwitches); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Console.Write("Number of Buttons: "); Console.CursorLeft = 30; Console.WriteLine(this.NumberOfButtons); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Console.Write("Power Source: "); Console.CursorLeft = 30; Console.WriteLine(this.PowerSource); Console.ForegroundColor = ConsoleColor.White; }
public virtual decimal GetPrice() { WidgetSmall SmallWidgetPrice = new WidgetSmall(); WidgetMedium MediumWidgetPrice = new WidgetMedium(); return((NumberOfSmallWidgets * SmallWidgetPrice.GetPrice()) + (NumberOfMediumWidgets * MediumWidgetPrice.GetPrice()) + (NumberOfSwitches * ComponentPricing.SwitchCostPerUnit) + (NumberOfButtons * ComponentPricing.ButtonCostPerUnit) + (ComponentPricing.GetPowerSourcePrice(PowerSource))); }