Create a class MathOperations, which should have 3 times method Add(), Exercises of Programming Languages

Method Add() has to be invoked with: • Add(int, int): int • Add(double, double, double): double • Add(decimal, decimal, decimal): decimal

Typology: Exercises

2021/2022

Uploaded on 06/24/2022

dragon-welsh
dragon-welsh 🇻🇳

5 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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------------
pf2

Partial preview of the text

Download Create a class MathOperations, which should have 3 times method Add() and more Exercises Programming Languages in PDF only on Docsity!

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(); } } }