2 Star 0 Fork 0

CS-IMIS-23/fwq20172303_Programming

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.idea
bin
docs
src
Experiment1
Experiment2
Experiment3
Huffman
New_week10
New_week2
New_week3
New_week4
New_week5
New_week6
New_week7
New_week8
New_week9
Project/Arithmetic
ArithmeticTest.java
Calculator.java
InfixToSuffix.java
MakeQuestions.java
Operand.java
RationalNumber.java
cn/edu/besti/cs1723/FWQ2303
week1
week10
week12
week2
week3
week4
week5
week6
week7
week8
week9
AutoCompileX.sh
LICENSE
README.md
run.sh
statistics.sh
克隆/下载
Operand.java 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
20172303 提交于 7年前 . 产生随机有理数
package Project.Arithmetic;
import java.util.Random;
public class Operand {
private Random rnd1 = new Random();
private Random rnd2 = new Random();
private Random rnd3 = new Random();
private RationalNumber b;
private String a, op1, op2, op3;
private int c, d;
// Random access to an integer and convert it to String type.
private String getA()
{
a = String.valueOf(rnd1.nextInt(10) + 1);
return a;
}
// Random access to a true fraction
private RationalNumber getB(){
while (1>0) {
c = rnd1.nextInt(10) + 1;
d = rnd2.nextInt(10) + 1;
b = new RationalNumber(c, d);
if (c < d)
{
break;
}
}
return b;
}
public Operand(){
}
// A random number of operands may be integers that may be fractions.
public String getOp1(){
if (rnd3.nextInt(2) == 0){
op1 = getA();
}
else
op1 = getB().toString();
return op1;
}
public String getOp2(){
if (rnd3.nextInt(2) == 0){
op2 = getA();
}
else
op2 = getB().toString();
return op2;
}
public String getOp3(){
if (rnd3.nextInt(2) == 0){
op3 = getA();
}
else
op3 = getB().toString();
return op3;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/CS-IMIS-23/fwq20172303_Programming.git
git@gitee.com:CS-IMIS-23/fwq20172303_Programming.git
CS-IMIS-23
fwq20172303_Programming
fwq20172303_Programming
master

搜索帮助