Wednesday, August 4, 2010

Program using abstract methods and abstract classes.


Write a program using abstract methods and abstract classes.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Csharp
{
    class AbstractClasses
    {
        public static void Main(string[] args)
        {
            cmmd obj = new cmmd();
            obj.add();
            obj.delete();
            obj.search();
            obj.update();
            Console.ReadLine();
        }
      
      
    }
    abstract class commands
    {
        public int a, b, res;
       
        public abstract void add();
            //uncommenting this lines generates an error;
        //{
        //    Console.WriteLine("The result operation is performed");
        //}
        public virtual void delete()
        {

        }
        public abstract void search();
       
        public void update()
        {
            Console.WriteLine("Performs update operations");
        }
    }
    class cmmd : commands
    {
        public override void add()
        {
            Console.WriteLine("Performs insertion operations");
        }

        public override void search()
        {
            Console.WriteLine("Performs search operations");
        }
        public override void delete()
        {
            Console.WriteLine("Performs delete operations");
        }
    }

No comments:

Post a Comment