using methods

Hello guys,

I have to create 2 methods first one is sumAmount.I have to get two parameters in Amount type and if amount x+amount y is bigger than 100 ,ı have to return true;

and in second , I have to create an enum called Calculation and it has 3 element like,sum,division and multiply.

and then I have to create second method called Calc and it has 3 parameters;

2 Amount and 1 in Calculation type and then İf Calculation type is sum ,i have to sum the 2 amount parameters and the result must return true(I have to use my first method in here)

if(Calculation type is Mutiply,i have to multiply the 2 amount parameters and the result must return true again

and it is going like that …

so far I wrote this below codes in Jobs.But I am not sure about it.Could you help me please?

public static boolean sumAmount(Amount x,Amount y)

{

return x+y>100;
}

public static int Calc(Amount a,Amount b,BuzCalcType c)
{
Amount sonuc;
if(BuzCalcType::sum)

{
result=a + b;
}

else if(BuzCalcType::divide)
{
result=a * b;

}

else if(BuzCalcType::multiply)
{
result=a/b;

}

print sumAmount(Amount a,Amount b);

}

Can you make it more clear? May be with an example.

What should the second method return?

it should return result and if result bigger than 100 it should retur true otherwise false
for example i have a=50 b=3 and ı chose calculation enum::multiply then result is 150 and bigger than 100 so ı have to return true. for bigger than 100 part I need method1 and second part of calculation I neeed method has 3 parameters. parameters like amount1,amount2 and Calculation(enum) and if a chose enum type multiply it has to make multiply between amount1 and amont2 and it must return true or false if it is bigger than 100 or not.

Please see, if this is what you are looking for.

static void XYZ(Args _args)
{
boolean sumCalc(Amount _x)
{
boolean ret;

if (_x > 100)
ret = true;

return ret;
}

Amount Calc(Amount _a, Amount _b, BuzCalcType _c)
{
Amount sonuc;

if(_c == BuzCalcType::Sum)
{
sonuc = _a + _b;
}
else if(_c == BuzCalcType::Multiply)
{
sonuc = _a * _b;
}
else if (_c == BuzCalcType::Divide)
{
sonuc = _b ? _a / _b : 0;
}

return sonuc;
}

info(strfmt("%1", sumCalc(Calc(1000, 1, BuzCalcType::Divide))));
}

I think thats why I look for it but" sonuc = _b ? _a / _b : 0;" what is that mean?and if I returned the first method with 2 parameters amount x and amount y and then return x+y>100 how can I change the info line info(strfmt("%1", sumCalc(Calc(1000, 1, BuzCalcType::Divide))));

Division by zero will return error. So check if there is value before doing the division.

You are already doing the operations in Calc. why do you have to do it again in other method?

actually I have to do in first method I have to take 2 parametrs thats why I am asking.calc(amount x,amount) it must be like that if I do like that in second method how can I change the info

info(strfmt("%1", sumCalc(_a, _b))); // Then you will not be using the other method Calc any more.