Tuesday, December 6, 2011

program operator seluler dalam C#


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

namespace ConsoleApplication33
{
    interface simcard
    {
        void call();
        void sms();
    }
    class xl : simcard
    {
        public void call()
        {
            Console.WriteLine("calling from xl");
        }
        public void sms()
        {
            Console.WriteLine("sms from xl");
        }
    }
    class telkomsel : simcard
    {
        public void call()
        {
            Console.WriteLine("calling from telkomsel");
        }
        public void sms()
        {
            Console.WriteLine("sms from telkomsel");
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            simcard sim;
            Console.WriteLine("pilih operator = ");
            Console.WriteLine(" 1. xl");
            Console.WriteLine(" 2. telkomsel");
            Console.Write(" Pilih ");
            int a = int.Parse(Console.ReadLine());
            if (a == 1)
            {
                sim = new xl();
                sim.call();
                sim.sms();
            }
            else
            if (a==2)
            {
                sim = new telkomsel();
                sim.call();
                sim.sms();
            }
        }
    }
}

No comments:

Post a Comment