C# Programming

Stingray12
Inheritance4.zip

Programming Using Inheritance/Programming Using Inheritance/.vs/Programming Using Inheritance/v16/.suo

Programming Using Inheritance/Programming Using Inheritance/Account.cs

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Programming_Using_Inheritance { class Account { //Declares the instance variable for the class private decimal Balance; private string AccountName; private int AccountNumber; //Creates the class constructor and initialize its instance variables using mutator methods public Account(decimal Balance, string AccountName, int AccountNumber) { setAccontNumber(AccountNumber); setAccountName(AccountName); //For the balance initialization to make sure it is greater than zero if (Balance >= 0) setBalance(Balance); else setBalance(Balance); } //Creates mutator methods to set balance, accountNumber and accountName public void setBalance(decimal Balance) { this.Balance = Balance; } public void setAccontNumber(int AccountNumber) { this.AccountNumber = AccountNumber; } public void setAccountName(string AccountName) { this.AccountName = AccountName; } //To get the instance field variables public decimal getBalance() { return this.Balance; } public int getAccontNumber() { return this.AccountNumber; } public string getAccountName() { return this.AccountName; } //Creates a credit method to add current balance to passed balance public void Credit(decimal Amount) { this.Balance += Amount; } //Creates a credit method to deduct current balance from passed balance and return the operation status whether successful or not public Boolean Debit(decimal Amount) { if (Amount <= Balance){ this.Balance -= Amount; return true; } else { Console.WriteLine("Insufficient Funds"); return false; } } //Prints the formatted result of current status of instance variables public void PrintAccount() { Console.WriteLine("Account Name:\t{0}\nAccount Number:\t{1}\nBalance:\t{2:c}\n",AccountName,AccountNumber,Balance); } } }

Programming Using Inheritance/Programming Using Inheritance/App.config

Programming Using Inheritance/Programming Using Inheritance/bin/Debug/Programming Using Inheritance.exe

Programming Using Inheritance/Programming Using Inheritance/bin/Debug/Programming Using Inheritance.exe.config

Programming Using Inheritance/Programming Using Inheritance/bin/Debug/Programming Using Inheritance.pdb

Programming Using Inheritance/Programming Using Inheritance/CheckingAccount.cs

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Programming_Using_Inheritance { //Extends the parent class class CheckingAccount : Account { private decimal FeeCharged; //Initializes the checking fee and pass call the base constructor of parent class public CheckingAccount(decimal Balance, string AccountName, int AccountNumber, decimal FeeCharge) : base(Balance, AccountName, AccountNumber) { setFeeAmount(FeeCharge); } //Sets the checking fee but first make sure the fee is greater than 0 public void setFeeAmount(decimal FeeAmount) { if (FeeAmount >= 0) this.FeeCharged = FeeAmount; else this.FeeCharged = 0; } //Credits the account by first deducting the checking fee public new void Credit(decimal Amount) { base.Credit(Amount - FeeCharged); } //Tries to debit the account by first checking if the debting process was successful. If successful then it adds a deduction fee public new void Debit(decimal Amount) { if(base.Debit(Amount)) { base.Debit(FeeCharged); } } //Prints formatted results of current status of instance variables public new void PrintAccount() { Console.WriteLine("Account Name:\t{0}\nAccount Number:\t{1}\nBalance:\t{2:c}\nFee Charged:\t{3:c}\n", getAccountName(), getAccontNumber(), getBalance(), FeeCharged); } } }

Programming Using Inheritance/Programming Using Inheritance/Class1.cs

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Programming_Using_Inheritance { class Class1 { } }

Programming Using Inheritance/Programming Using Inheritance/Class2.cs

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Programming_Using_Inheritance { class Class2 { } }

Programming Using Inheritance/Programming Using Inheritance/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs

// <autogenerated /> using System; using System.Reflection; [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]

Programming Using Inheritance/Programming Using Inheritance/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache

Programming Using Inheritance/Programming Using Inheritance/obj/Debug/Programming Using Inheritance.csproj.AssemblyReference.cache

Programming Using Inheritance/Programming Using Inheritance/obj/Debug/Programming Using Inheritance.csproj.CoreCompileInputs.cache

026cec76836a0225d44f26dc85a994df45ff0746

Programming Using Inheritance/Programming Using Inheritance/obj/Debug/Programming Using Inheritance.csproj.FileListAbsolute.txt

C:\Users\ciann\source\repos\Programming Using Inheritance\obj\Debug\Programming Using Inheritance.csproj.AssemblyReference.cache C:\Users\ciann\source\repos\Programming Using Inheritance\obj\Debug\Programming Using Inheritance.csproj.CoreCompileInputs.cache C:\Users\ciann\source\repos\Programming Using Inheritance\bin\Debug\Programming Using Inheritance.exe.config C:\Users\ciann\source\repos\Programming Using Inheritance\bin\Debug\Programming Using Inheritance.exe C:\Users\ciann\source\repos\Programming Using Inheritance\bin\Debug\Programming Using Inheritance.pdb C:\Users\ciann\source\repos\Programming Using Inheritance\obj\Debug\Programming Using Inheritance.exe C:\Users\ciann\source\repos\Programming Using Inheritance\obj\Debug\Programming Using Inheritance.pdb

Programming Using Inheritance/Programming Using Inheritance/obj/Debug/Programming Using Inheritance.exe

Programming Using Inheritance/Programming Using Inheritance/obj/Debug/Programming Using Inheritance.pdb

Programming Using Inheritance/Programming Using Inheritance/Program.cs

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Programming_Using_Inheritance { class Program { static void Main(string[] args) { //Instantiate the classes by values CheckingAccount checking = new CheckingAccount(1000,"Doe-Checking",1,3); SavingsAccount savings = new SavingsAccount(2000, "Doe-Saving", 2, 5); checking.PrintAccount(); savings.PrintAccount(); Console.WriteLine("Deposit $100 into checking"); checking.Credit(100); checking.PrintAccount(); Console.WriteLine("Withdraw $50 from checking"); checking.Debit(50); checking.PrintAccount(); Console.WriteLine("Withdraw $6,000 from checking"); checking.Debit(6000); checking.PrintAccount(); Console.WriteLine("Deposit $3,000 into savings"); savings.Credit(3000); savings.PrintAccount(); Console.WriteLine("Withdraw $200 from savings"); savings.Debit(200); savings.PrintAccount(); Console.WriteLine("Calculate interest on savings"); savings.Credit(savings.CalculateInterest()); savings.PrintAccount(); Console.WriteLine("Withdraw $10,000 from savings"); savings.Debit(10000); savings.PrintAccount(); Console.WriteLine("Press the [Enter] key to continue."); Console.ReadLine(); } } }

Programming Using Inheritance/Programming Using Inheritance/Programming Using Inheritance.csproj

Debug AnyCPU {DBC30B10-A9C4-4152-AB04-5DA51B4D73ED} Exe Programming_Using_Inheritance Programming Using Inheritance v4.7.2 512 true true AnyCPU true full false bin\Debug\ DEBUG;TRACE prompt 4 AnyCPU pdbonly true bin\Release\ TRACE prompt 4

Programming Using Inheritance/Programming Using Inheritance/Programming Using Inheritance.sln

Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.32106.194 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Programming Using Inheritance", "Programming Using Inheritance.csproj", "{DBC30B10-A9C4-4152-AB04-5DA51B4D73ED}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {DBC30B10-A9C4-4152-AB04-5DA51B4D73ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DBC30B10-A9C4-4152-AB04-5DA51B4D73ED}.Debug|Any CPU.Build.0 = Debug|Any CPU {DBC30B10-A9C4-4152-AB04-5DA51B4D73ED}.Release|Any CPU.ActiveCfg = Release|Any CPU {DBC30B10-A9C4-4152-AB04-5DA51B4D73ED}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {F4366C02-33AA-4BAB-B042-586D1496F678} EndGlobalSection EndGlobal

Programming Using Inheritance/Programming Using Inheritance/Properties/AssemblyInfo.cs

using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Programming Using Inheritance")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Programming Using Inheritance")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("dbc30b10-a9c4-4152-ab04-5da51b4d73ed")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]

Programming Using Inheritance/Programming Using Inheritance/SavingsAccount.cs

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Programming_Using_Inheritance { //Extends the parent class account class SavingsAccount : Account { private double InterestRate; //Initializes the interest-rate and pass call the base constructor of parent class public SavingsAccount(decimal Balance, string AccountName, int AccountNumber, double InterestRate) : base(Balance, AccountName, AccountNumber) { setInterestRate(InterestRate); } //Creates a mutator method for setting interest rate by first ensuring the passed value is greater than zero public void setInterestRate(double InterestRate) { if (InterestRate >= 0) this.InterestRate = InterestRate; else this.InterestRate = 0.0; } //The call interest method will be calculating the interest by multiplying current balance bt rate in percentage then returning the results public decimal CalculateInterest() { return (decimal)(InterestRate/100) * getBalance(); } //Prints the formatted result of current status of instance variables public new void PrintAccount() { Console.WriteLine("Account Name:\t{0}\nAccount Number:\t{1}\nBalance:\t{2:c}\nInterest Rate:\t{3}%\n", getAccountName(), getAccontNumber(), getBalance(),InterestRate); } } }