📄 mymathimpl.java
字号:
package lee;
import java.lang.Math;
/**
* @author yeeku.H.lee kongyeeku@163.com
* @version 1.0
* <br>Copyright (C), 2005-2008, yeeku.H.Lee
* <br>This program is protected by copyright laws.
* <br>Program Name:
* <br>Date:
*/
public class MyMathImpl implements MyMath
{
private Author author;
public void setAuthor(Author author)
{
this.author = author;
}
public String copyRight()
{
return "版权保留\n" + author.info();
}
public double oneEquation(double a , double b)throws MyMathException
{
if (a == 0)
{
System.out.println("参数错误");
throw new MyMathException("参数错误");
}
else
{
return -b/a;
}
}
public double[] twoEquation(double a , double b , double c)throws MyMathException
{
double[] result ;
if (a == 0)
{
System.out.println("参数错误");
throw new MyMathException("参数错误");
}
else if(b * b - 4 * a * c < 0)
{
System.out.println("方程在有理数范围内无解");
result = null;
return result;
}
else if(b * b - 4 * a * c == 0)
{
System.out.println("方程在有唯一解");
result = new double[1];
result[0] = -b/(2 * a);
return result;
}
else
{
System.out.println("方程在有两个解");
result = new double[2];
result[0] = (-b + Math.sqrt(b * b - 4 * a * c))/2/a;
result[1] = (-b - Math.sqrt(b * b - 4 * a * c))/2/a;
return result;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -