Bassmansam
10-16-2009, 02:18 PM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CalculatorApplication
{
interface iCalculator
{
decimal add(decimal a, decimal b);
// void subtract(decimal a, decimal b);
// void divide(decimal a, decimal b);
//void multiply(decimal a, decimal b);
}
}
Interface
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CalculatorApplication
{
public class Calculator: iCalculator
{
public static decimal result;
public decimal add(decimal a, decimal b)
{
result = a + b;
return result;
}
}
}
Class with method implemented
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CalculatorApplication
{
class Class1 : iCalculator
{
decimal k = Calculator.result;
// decimal add(decimal a, decimal b);
public decimal round(decimal j)
{
j = Math.Round(k, 2);
return j;
}
}
}
The problem is here , I am trying to use this class to round the result's from the Calculator class to two decimals , but i can't get it to work. Anyone got any ideas? Thanks
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CalculatorApplication
{
interface iCalculator
{
decimal add(decimal a, decimal b);
// void subtract(decimal a, decimal b);
// void divide(decimal a, decimal b);
//void multiply(decimal a, decimal b);
}
}
Interface
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CalculatorApplication
{
public class Calculator: iCalculator
{
public static decimal result;
public decimal add(decimal a, decimal b)
{
result = a + b;
return result;
}
}
}
Class with method implemented
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CalculatorApplication
{
class Class1 : iCalculator
{
decimal k = Calculator.result;
// decimal add(decimal a, decimal b);
public decimal round(decimal j)
{
j = Math.Round(k, 2);
return j;
}
}
}
The problem is here , I am trying to use this class to round the result's from the Calculator class to two decimals , but i can't get it to work. Anyone got any ideas? Thanks