Created
July 22, 2014 03:28
-
-
Save nastajus/b83db49fca0ce470d1ab to your computer and use it in GitHub Desktop.
Poly practice per Zack for me from here: http://tutorials.csharp-online.net/Inheritance_and_Polymorphism%E2%80%94Exercises
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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