Skip to content

Instantly share code, notes, and snippets.

@TheBuzzSaw
Created November 15, 2022 23:03
Show Gist options
  • Save TheBuzzSaw/ae60342145822c1a69f787ed6b8ed8e4 to your computer and use it in GitHub Desktop.
Save TheBuzzSaw/ae60342145822c1a69f787ed6b8ed8e4 to your computer and use it in GitHub Desktop.
Animalz
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Runtime.CompilerServices;
using LanguageExt;
namespace Kelly;
interface IBrian
{
}
interface IAnimal
{
void Pet();
void Feed();
//void Bathe();
static IAnimal operator +(IAnimal a, IAnimal b) => null;
}
interface IBigEaredCreature
{
void FlapEars();
}
struct Frog : IAnimal
{
public void Feed()
{
Console.WriteLine("ribbit");
}
public void Pet()
{
Console.WriteLine("ribbit");
}
public static bool AreCats() => false;
}
class Cat : IAnimal
{
private int interactionCount = 0;
public void Feed()
{
this.interactionCount++;
Console.WriteLine("Om nom nom nom" + interactionCount);
}
public void Pet()
{
Console.WriteLine("PURRRRRRR");
}
}
class Dog : IAnimal, IBigEaredCreature
{
public void Feed()
{
Console.WriteLine("slobber slobber");
}
public void FlapEars()
{
Console.WriteLine("flap");
}
public void Pet()
{
Console.WriteLine("pant pant pant pant");
}
public static bool AreCats() => false;
}
class Program
{
static void InteractWithAnimal(IAnimal animal)
{
animal.Feed();
animal.Pet();
}
static void PetAnimal(IAnimal animal)
{
animal.Pet();
}
static void Main(string[] args)
{
var kylo = new Dog();
Dog.AreCats();
InteractWithAnimal(kylo);
InteractWithAnimal(kylo);
InteractWithAnimal(kylo);
var king = new Dog();
InteractWithAnimal(king);
var linux = new Cat();
InteractWithAnimal(linux);
InteractWithAnimal(linux);
var fable = new Cat();
InteractWithAnimal(fable);
InteractWithAnimal(linux);
InteractWithAnimal(new Frog());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment