//15 Return a type class with a method. public BudgetActivity ShowAccountActivity() { //15 return new BudgetActivity(); //16 object BudgetActivity activity = new BudgetActivity(); //17 set up some activity decimal balance = 0; foreach (decimal deposit in deposits) { //21 - Keep track of highest and lowest //However on Math. Show function F12 here to see the docs activity.High = Math.Max(deposit, activity.High); activity.Low = Math.Min(deposit, activity.Low); //22 -back to program balance += deposit; } //19 Get the average activity.Average = balance / deposits.Count; return(activity); }
static void Main(string[] args) { //23 Go to bin/debug on cmd and show how you can run the program //24 Right click on References //Add reference - dig down into the Object Explorer //Choose Speech() //Choose ctrl . SpeechSynthesizer speak = new SpeechSynthesizer(); // speak.Speak("Hey, you are rich!"); //5 BudgetSheet sheet = new BudgetSheet(); sheet.DepositMoney(120.0M); sheet.DepositMoney(1000.0M); sheet.DepositMoney(800.0M); //8 set a break point //11 Talk about reference types & pointers. //BudgetSheet sheet2 = sheet; //22 Activity BudgetActivity activity = sheet.ShowAccountActivity(); Console.WriteLine(activity.Average); Console.WriteLine(activity.High); Console.WriteLine(activity.Low); ShowBudget("Average", activity.Average); ShowBudgetAgain("Average", activity.Average); if (activity.Average < 800) { speak.Speak("Alert your account is looking low"); } Console.ReadLine(); }