Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- /* C# Example of Abstratcion: An application for mobile manufacturing company - Every phone must have to implement caller
- * and sms feature but it depends on company to company (or model to model) if they want to include other features or not
- * which are readily available , you just have to use it without knowing its implementation (like facebook in this example).
- */
- namespace AbstractTest
- {
- public abstract class feature
- {
- public abstract void Caller();
- public abstract void SMS();
- public void facebook()
- {
- Console.WriteLine("You are using facebook");
- }
- }
- public class Iphone : feature
- {
- public override void Caller()
- {
- Console.WriteLine("iPhone caller feature");
- }
- public override void SMS()
- {
- Console.WriteLine("iPhone sms feature");
- }
- public void otherFeature()
- {
- facebook();
- }
- }
- public class Nokia : feature
- {
- public override void Caller()
- {
- Console.WriteLine("Nokia caller feature");
- }
- public override void SMS()
- {
- Console.WriteLine("Nokia sms feature");
- }
- public void otherFeature()
- {
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Iphone c1 = new Iphone();
- c1.Caller();
- c1.SMS();
- c1.otherFeature();
- Nokia n1 = new Nokia();
- n1.Caller();
- n1.SMS();
- n1.otherFeature();
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement