Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Abstraction c#
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; namespace Rextester { public class Program { public static void Main(string[] args) { /*BaseEmployee Object can not be created since this is declared as Abstract Following LOCs will return compilation error if uncommented.*/ //BaseEmployee baseEmployee = new BaseEmployee(); //baseEmployee.EmployeeID = "EMP001"; //baseEmployee.EmployeeAddress = "3400 Lee Highway, VA 22031"; //baseEmployee.EmployeeName = "John Doe"; //Base Employee Calculate Salary can be called that shouldn't be accessible //var baseSalary = baseEmployee.CalculateSalary(34); //SalesExecutive and Manager objects are successfully created. Car Dc = new driver(); Dc.details(); Mechanic m= new Mechanic(); Console.WriteLine("Formula is:"+m.DisplayMakeFormula()); } } public abstract class Car { public string modelname { get; set; } public string color { get; set; } public abstract void details(); } public class driver : Car { public override void details() { modelname = "innova"; Console.WriteLine("Car model name:"+modelname); color = "white"; Console.WriteLine("Car color:"+color); } } public class Mechanic: Car { private string formula = "a*b"; private string GetEngineMakeFormula() { return formula; } public string DisplayMakeFormula() { //"GetEngineMakeFormula()" is private but accessible and limited to this class only return GetEngineMakeFormula(); } public override void details() { modelname = "innova"; Console.WriteLine("Car model name:"+modelname); color = "white"; Console.WriteLine("Car color:"+color); } } }
run
|
edit
|
history
|
help
0
Added Carnival, List Matching
ConcurrentStack<T>
Unsorted array with most occurence
Z_non_pow
testing DT Serialization
Overloading
The modifier 'private' is not valid for this item
Math 9.6
1
min tree