2024-11-29 15:35:19 +04:00
|
|
|
|
using laba3.Core;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace laba3.Subprograms
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CLI math game "Gusess the answer";
|
|
|
|
|
/// Player need to guess result of math function;
|
|
|
|
|
/// </summary>
|
2024-12-14 14:49:42 +04:00
|
|
|
|
public class GuessAnswerMath
|
2024-11-29 15:35:19 +04:00
|
|
|
|
{
|
|
|
|
|
private const double PI = Math.PI;
|
|
|
|
|
private const double E = Math.E;
|
2024-12-14 14:49:42 +04:00
|
|
|
|
private double a;
|
|
|
|
|
private double b;
|
|
|
|
|
private double result;
|
2024-11-29 15:35:19 +04:00
|
|
|
|
|
2024-12-14 14:49:42 +04:00
|
|
|
|
public void setArgs(double a, double b)
|
2024-11-29 15:35:19 +04:00
|
|
|
|
{
|
2024-12-14 14:49:42 +04:00
|
|
|
|
this.a = a;
|
|
|
|
|
this.b = b;
|
2024-11-29 15:35:19 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-14 14:49:42 +04:00
|
|
|
|
public void ComputeResult()
|
2024-11-29 15:35:19 +04:00
|
|
|
|
{
|
2024-12-14 14:49:42 +04:00
|
|
|
|
this.result = Math.Sin((Math.Pow(a, 3) + Math.Pow(b, 5)) / (2 * PI)) + Math.Pow(Math.Cos(a + b), (1.0 / 3.0));
|
2024-11-29 15:35:19 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-12-14 14:49:42 +04:00
|
|
|
|
public bool CheckArgs()
|
2024-11-29 15:35:19 +04:00
|
|
|
|
{
|
|
|
|
|
return Math.Cos(a + b) >= 0;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-14 14:49:42 +04:00
|
|
|
|
public double GetResult()
|
2024-11-29 15:35:19 +04:00
|
|
|
|
{
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|