static void Main(string[] args) { //Animal cat = new Animal(1, "Garfield", "Cat"); //Animal dog = new Animal(2, "Bark", "Dog"); //Dog dog = new Dog(); //dog.Id = 2; //dog.Name = "Bark"; //dog.Type = "Dog"; Dog dog = new Dog(2, "Bark", "Sharplaninec"); Cat cat = new Cat("High", "High", 1, "Garfield"); Console.WriteLine(dog.Eat()); Console.WriteLine(cat.GetInfo()); Console.WriteLine(dog.Bark()); Console.WriteLine(cat.Meow()); Tiger tiger = new Tiger("Low", "Medium", 3, "TigerName"); Console.WriteLine(tiger.Meow()); Console.WriteLine(cat.Eat()); Console.WriteLine(tiger.Eat()); //Demo ENUMS Human human = new Human("Risto", "Panchevski", new DateTime(1989, 7, 20), Days.Sun); Console.WriteLine(human.GetInfo()); }
static void Main(string[] args) { Dog spotty = new Dog(); spotty.name = "Spotty"; spotty.age = 4; spotty.happiness = 0.5f; spotty.spotCount = 25; spotty.PrintBase(); spotty.Bark(); Console.WriteLine("New Happiness: " + spotty.happiness); Console.WriteLine(); Cat heisenberg = new Cat(); heisenberg.name = "Heisenberg"; heisenberg.age = 13; heisenberg.happiness = 0.3f; heisenberg.cuteness = 0.4f; heisenberg.PrintBase(); heisenberg.Meow(); Console.ReadKey(); }
static void Main(string[] args) { // Creating instances of all animals to see what constructors will be called // All animals have access to methods from Animal Animal dambo = new Animal() { Name = "Dambo", Id = 5, Type = "Elephant" }; dambo.PrintInfo(); dambo.Eat(); Console.WriteLine("----------------------------------------------------------"); Dog spark = new Dog() { Name = "Spark", Id = 2, Type = "Dog", Race = "Labrador" }; spark.PrintInfo(); spark.Eat(); spark.Bark(); Console.WriteLine("----------------------------------------------------------"); Cat garfield = new Cat() { Name = "Garfield", Id = 3, Lazyness = "Very" }; // We don't tell the type here because the constructor will set it garfield.PrintInfo(); garfield.Eat(); garfield.Meow(); Console.ReadLine(); }
static void Main(string[] args) { Dog jango = new Dog() { Id = 1, Name = "Jango", //Type = "Dog", Race = "Poodle" }; jango.PrintInfo(); jango.Eat(); jango.Bark(); Console.WriteLine(); Animal dambo = new Animal() { Id = 2, Name = "Dambo", Type = AnimalTypes.Other }; dambo.PrintInfo(); dambo.Eat(); Console.WriteLine(); Cat kitty = new Cat() { Id = 3, Name = "Kitty", //Type = "Cat", Laziness = "Very lazy" }; kitty.PrintInfo(); kitty.Meow(); kitty.Eat(); Console.WriteLine(); WeekDays tuesday = WeekDays.Tuesday; Console.WriteLine(tuesday); Console.WriteLine(tuesday.ToString() == "Tuesday"); Console.WriteLine(tuesday == (WeekDays)2); Console.WriteLine(); Mouse mouse = new Mouse(); }
static void Main(string[] args) { Console.WriteLine(Helper.Multiply(6, 8)); Cat a = new Cat("John", "The cat"); a.Price = Helper.Randomize(); a.Meow(); Dog b = new Dog("Mike", "The dog"); b.Price = Helper.Randomize(); b.Bark(); }
static void Main(string[] args) { Dog objDog = new Dog(); objDog.Bark(); objDog.Eat(); Console.WriteLine("//////////////////////////"); Cat objCat = new Cat(); objCat.Meow(); objCat.Eat(); Console.ReadLine(); }
static void Main(string[] args) { Puppy puppy = new Puppy();//Multiple Inheritance puppy.Eat(); puppy.Bark(); puppy.Weep(); Dog dog = new Dog();//Single Inheritance dog.Bark(); dog.Eat(); Cat cat = new Cat();//Heirarchial Inheritance cat.Meow(); cat.Eat(); }
static void Main(string[] args) { Animal dumbo = new Animal() { Id = 1, Name = "Dumbo", Type = "elephant", // IsHappy = true - we can't access this here }; dumbo.PrintInfo(); dumbo.Eat(); Console.WriteLine("-----------------------------------------"); Dog baron = new Dog() { Id = 2, Type = "dog", Name = "Barron", Race = "German sheppard" }; baron.PrintInfo(); baron.Eat(); baron.Bark(); baron.IsDogHappy(); Console.WriteLine("-----------------------------------------"); Cat garfield = new Cat() { Id = 3, Name = "Garfield", Laziness = "very much" }; // we don't tell the type here garfield.PrintInfo(); garfield.Eat(); garfield.Meow(); Console.WriteLine("-----------------------------------------"); Console.ReadLine(); }
static void Main(string[] args) { //Console.WriteLine("Single Inheritance"); /*Console.WriteLine("Multiple Inheritance"); * Puppy puppy = new Puppy(); * puppy.Eat(); * puppy.Bark(); * puppy.Weep();*/ Console.WriteLine("Hierarchial Inheritance"); Dog dog = new Dog(); dog.Eat(); dog.Bark(); Cat cat = new Cat(); cat.Eat(); cat.Meow(); }
static void Main(string[] args) { Dog myDog = new Dog(); myDog.Eat(); myDog.Bark(); Console.WriteLine(); Puppy myPyppy = new Puppy(); myPyppy.Eat(); myPyppy.Bark(); myPyppy.Weep(); Console.WriteLine(); Cat myCat = new Cat(); myCat.Eat(); myCat.Meow(); }
static void Main(string[] args) { Animal animal = new Animal() { Id = 1, Name = "Ben", Type = "Dog", }; Dog majlo = new Dog() { Id = 2, Name = "Majlo", Type = "Dog", Breed = "Husky" }; Cat garfild = new Cat() { Id = 3, Name = "Garfild", Lazyness = "Very" }; Tiger tiger = new Tiger() { Id = 4, Name = "Tiger", Lazyness = "Non", }; animal.Eat(); majlo.Eat(); garfild.Eat(); garfild.Meow(); tiger.Eat(); tiger.Meow(); tiger.PrintInfo(); Console.ReadLine(); }
static void Main(string[] args) { Dog fido = new Dog(); Puppy puppy = new Puppy(); Cat cat = new Cat(); Console.WriteLine("Fido:"); fido.Eat(); fido.Bark(); Console.WriteLine(); Console.WriteLine("Puppy:"); puppy.Eat(); puppy.Bark(); puppy.Weep(); Console.WriteLine(); Console.WriteLine("Cat:"); cat.Eat(); cat.Meow(); }
static void Main(string[] args) { Animal animal = new Animal(); Console.WriteLine(animal.Eat()); Dog dog = new Dog(); Console.WriteLine(dog.Eat()); Console.WriteLine(dog.Bark()); Cat cat = new Cat(); Console.WriteLine(cat.Eat()); Console.WriteLine(cat.Meow()); Puppy puppy = new Puppy(); Console.WriteLine(puppy.Eat()); Console.WriteLine(puppy.Bark()); Console.WriteLine(puppy.Weep()); }
static void Main(string[] args) { Console.WriteLine("Inheritance in C#!"); Console.WriteLine("------------------------------"); Animal dumbo = new Animal() { Id = 1, Name = "Dumbo", Type = "elephant" // IsHappy = true - we can't access it here it's protected }; dumbo.PrintInfo(); dumbo.Eat(); Console.WriteLine("------------------------------"); Dog vele = new Dog() { Id = 2, Type = "dog", Name = "Vele", Breed = "dzukela" }; vele.PrintInfo(); vele.Eat(); vele.Bark(); vele.IsDogHappy(); Console.WriteLine("------------------------------"); Cat garfield = new Cat() { Id = 3, Name = "Garfield", Laziness = "very much" }; // we don't tell the type garfield.PrintInfo(); garfield.Eat(); // another overload is garfield.Eat("fish"); garfield.Meow(); Console.WriteLine("------------------------------"); #region Enums // Enumerators Console.WriteLine(DayOfWeek.Tuesday); DiscountDay dayOne = new DiscountDay() { Discount = 10, Day = DayOfWeek.Monday }; Console.WriteLine($"On {dayOne.Day} you would have {dayOne.Discount}% discount"); int dayOneInteger = (int)dayOne.Day; Console.WriteLine(dayOneInteger); // casting into integer DateTime today = DateTime.Now; // casting into integer int dayWeekToday = (int)today.DayOfWeek; Console.WriteLine(dayWeekToday); #endregion Console.ReadLine(); }