

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Method Add() has to be invoked with: • Add(int, int): int • Add(double, double, double): double • Add(decimal, decimal, decimal): decimal
Typology: Exercises
1 / 2
This page cannot be seen from the preview
Don't miss anything!


using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Object_Oriented_Programming { internal interface IDrawable { void Draw(); } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Object_Oriented_Programming { internal class MathOperations { public int Add(int a, int b) { return a + b; } public double Add(double a, double b, double c) { return a + b + c; } public decimal Add(decimal a, decimal b, decimal c) { return a + b + c; } } } using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Object_Oriented_Programming { internal class OOP { static void Main(string[] args) { //-----------Shapes------------
int radius = int.Parse(Console.ReadLine()); IDrawable circle = new Circle(radius); int width = int.Parse(Console.ReadLine()); int height = int.Parse(Console.ReadLine()); IDrawable rectangle = new Rectangle(width, height); circle.Draw(); rectangle.Draw(); //-----------Math Operation---------- MathOperations mathOperations = new MathOperations(); Console.WriteLine(mathOperations.Add(2, 3)); Console.WriteLine(mathOperations.Add(2.2, 3.3, 5.5)); Console.WriteLine(mathOperations.Add(2.2m, 3.3m, 4.4m)); //-----------Animals------------ Animal cat = new Cat("Pesho", "Whiskas"); Animal dog = new Dog("Gosho", "Meat"); Console.WriteLine(cat.ExplainSelf()); Console.WriteLine(dog.ExplainSelf()); Console.ReadLine(); } } }