static void Main(string[] args) { SavingsAccount s1 = new SavingsAccount(50); SavingsAccount s2 = new SavingsAccount(100); SavingsAccount.SetInterestRate(0.8); Console.WriteLine("Interest rate is: {0}", SavingsAccount.GetInterestRate()); SavingsAccount s3 = new SavingsAccount(10000.75); Console.WriteLine("Interest rate is: {0}", SavingsAccount.GetInterestRate()); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("***** Fun with static data *****\n"); SavingsAccount s1 = new SavingsAccount(50); Console.WriteLine("Interest rate is: {0}", SavingsAccount.InterestRate); //try to change the interestRate via property... SavingsAccount.SetInterestRate(0.08); SavingsAccount s2 = new SavingsAccount(100); Console.WriteLine("Interest rate is: {0}", SavingsAccount.InterestRate); //making a 3rd object does NOT reset the interest rate SavingsAccount s3 = new SavingsAccount(10000.75); Console.WriteLine("Interest rate is: {0}", SavingsAccount.InterestRate); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("***** Fun with Static Data *****\n"); SavingsAccount s1 = new SavingsAccount(50); Console.WriteLine("Interest Rate is: {0}", SavingsAccount.GetInterestRate()); SavingsAccount.SetInterestRate(0.08); SavingsAccount s2 = new SavingsAccount(100); Console.WriteLine("Interest Rate is: {0}", SavingsAccount.GetInterestRate()); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("***** Fun with Static Data *****\n"); // Make an account. SavingsAccount s1 = new SavingsAccount(50); // Print the current interest rate. Console.WriteLine("Interest Rate is: {0}", SavingsAccount.GetInterestRate()); // Try to change the interest rate via property. SavingsAccount.SetInterestRate(0.08); // Make a second account. SavingsAccount s2 = new SavingsAccount(100); // Should print 0.08...right?? Console.WriteLine("Interest Rate is: {0}", SavingsAccount.GetInterestRate()); Console.ReadLine(); }