ScaleXDecorator done
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Functions.Decorator
|
||||
{
|
||||
public class LimXDecorator : FunctionDecorator
|
||||
{
|
||||
private double leftBound;
|
||||
private double rightBound;
|
||||
public LimXDecorator(IOneVariableFunction function, double leftBound, double rightBound) : base(function)
|
||||
{
|
||||
this.leftBound = leftBound;
|
||||
this.rightBound = rightBound;
|
||||
}
|
||||
public override bool Check()
|
||||
{
|
||||
return base.Check();
|
||||
}
|
||||
public override double GetByX(double xValue)
|
||||
{
|
||||
if (xValue > leftBound && xValue < rightBound)
|
||||
{
|
||||
return base.GetByX(xValue);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Functions.Decorator
|
||||
{
|
||||
public class ScaleXDecorator : FunctionDecorator
|
||||
{
|
||||
private double factor;
|
||||
public ScaleXDecorator(IOneVariableFunction function, double factor) : base(function)
|
||||
{
|
||||
this.factor = factor;
|
||||
Name = $"{function.Name}, y=f({factor}x)";
|
||||
}
|
||||
public override bool Check()
|
||||
{
|
||||
return base.Check();
|
||||
}
|
||||
public override double GetByX(double xValue)
|
||||
{
|
||||
return base.GetByX(factor * xValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user