Skip to content

Instantly share code, notes, and snippets.

@nastajus
Created July 22, 2014 03:28
Show Gist options
  • Save nastajus/b83db49fca0ce470d1ab to your computer and use it in GitHub Desktop.
Save nastajus/b83db49fca0ce470d1ab to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/*
* Polymorphism practice. Doing exercises selected by Zack for me.
* http://tutorials.csharp-online.net/Inheritance_and_Polymorphism%E2%80%94Exercises
*
*/
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
ElectronicTelephone et = new ElectronicTelephone();
Console.WriteLine( et.Ring() );
Console.ReadLine();
}
}
abstract class Telephone
{
protected string phonetype;
public abstract string Ring()
{
return "Ringing the " + phonetype;
}
}
class ElectronicTelephone : Telephone
{
public ElectronicTelephone()
{
phonetype = "Digital";
}
public override string Ring()
{
return "Da " + phonetype + " makes funky noises.";
}
}
class DigitalPhone : Telephone
{
public override string Ring()
{
throw new NotImplementedException();
}
}
class TalkingPhone : Telephone
{
public override string Ring()
{
throw new NotImplementedException();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment