-
-
Save codecademydev/9e37603c030163b1b3b9f9d975c51397 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains 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
// Archmage.cs | |
using System; | |
namespace MagicalInheritance | |
{ | |
class Archmage: Mage | |
{ | |
public Archmage(string title) : base(title) {} | |
public override Storm CastRainStorm() | |
{ | |
return new Storm("rain", true, Title); | |
} | |
public Storm CastLightningStorm() | |
{ | |
return new Storm("lightning", true, Title); | |
} | |
} | |
} |
This file contains 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
// Mage.cs | |
using System; | |
namespace MagicalInheritance | |
{ | |
class Mage: Pupil | |
{ | |
public Mage(string title) : base(title) {} | |
public virtual Storm CastRainStorm() | |
{ | |
return new Storm("rain", false, Title); | |
} | |
} | |
} |
This file contains 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; | |
namespace MagicalInheritance | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Storm ZulRajasStorm = new Storm("wind", false, "Zul'rajas"); | |
Console.WriteLine(ZulRajasStorm.Announce()); | |
Pupil MezilKree = new Pupil("Mezil-Kree"); | |
Storm MezilKreeStorm = MezilKree.CastWindStorm(); | |
Console.WriteLine(MezilKreeStorm.Announce()); | |
Mage GulDan = new Mage("Gul’dan"); | |
Storm GulDanRainStorm = GulDan.CastRainStorm(); | |
Console.WriteLine(GulDanRainStorm.Announce()); | |
Archmage NielasAran = new Archmage("Nielas Aran"); | |
Storm NielasAranRainStorm = GulDan.CastRainStorm(); | |
Console.WriteLine(NielasAranRainStorm.Announce()); | |
Storm NielasAranLightningStorm = NielasAran.CastLightningStorm(); | |
Console.WriteLine(NielasAranLightningStorm.Announce()); | |
} | |
} | |
} |
This file contains 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
// Pupil.cs | |
using System; | |
namespace MagicalInheritance | |
{ | |
class Pupil { | |
public string Title { get; private set; } | |
public Pupil(string title) | |
{ | |
Title = title; | |
} | |
public Storm CastWindStorm() | |
{ | |
return new Storm("wind", false, Title); | |
} | |
} | |
} |
This file contains 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
// Storm.cs | |
using System; | |
namespace MagicalInheritance | |
{ | |
class Storm | |
{ | |
string Essence { get; set; } | |
bool IsStrong { get; set; } | |
string Caster { get; set; } | |
public Storm(string essence, bool isStrong, string caster) | |
{ | |
Essence = essence; | |
IsStrong = isStrong; | |
Caster = caster; | |
} | |
public string Announce() | |
{ | |
return $"{Caster} cast a {(IsStrong ? "strong" : "weak")} {Essence} storm!"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment