|
13 | 13 | ```java
|
14 | 14 | package zhao.algorithmMagic;
|
15 | 15 |
|
| 16 | +import zhao.algorithmMagic.core.AlgorithmStar; |
| 17 | +import zhao.algorithmMagic.core.FractionFactory; |
| 18 | +import zhao.algorithmMagic.operands.fraction.Fraction; |
| 19 | + |
| 20 | +public class MAIN1 { |
| 21 | + public static void main(String[] args) { |
| 22 | + // 获取分数操作数工厂 |
| 23 | + final FractionFactory fractionFactory = AlgorithmStar.fractionFactory(); |
| 24 | + // 准备三个操作数 |
| 25 | + final Fraction parse1 = fractionFactory.parse(1, 2); |
| 26 | + final Fraction parse2 = fractionFactory.parse(2); |
| 27 | + final Fraction parse3 = fractionFactory.parse("1 / 2"); |
| 28 | + |
| 29 | + System.out.println("打印三个分数"); |
| 30 | + System.out.println(parse1); |
| 31 | + System.out.println(parse2); |
| 32 | + System.out.println(parse3); |
| 33 | + |
| 34 | + System.out.println("全部通分 分别将分母变为 10 5 1 在这里我们将第一个分数保存一下 稍后用于约分"); |
| 35 | + final Fraction cf1 = parse1.cf(10); |
| 36 | + System.out.println(cf1); |
| 37 | + System.out.println(parse2.cf(5)); |
| 38 | + System.out.println(parse3.cf(1)); |
| 39 | + |
| 40 | + System.out.println("将被通分的 cf1 进行约分 不出意外的话 这里打印的值为 1 / 2"); |
| 41 | + System.out.println(cf1.simplify()); |
| 42 | + |
| 43 | + System.out.println("在这里将 parse1 以及 parse2 进行加减乘除计算"); |
| 44 | + System.out.println(parse1.add(parse2)); |
| 45 | + System.out.println(parse1.diff(parse2)); |
| 46 | + System.out.println(parse1.multiply(parse2)); |
| 47 | + System.out.println(parse1.divide(parse2)); |
| 48 | + |
| 49 | + System.out.println("在这里将 parse1 做为Java中的数值类型进行使用"); |
| 50 | + System.out.println(parse1.doubleValue()); |
| 51 | + } |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +* To obtain new help information, you can directly obtain the help document through the following methods, which |
| 56 | + includes more comprehensive API instructions |
| 57 | + |
| 58 | +```java |
| 59 | +package zhao.algorithmMagic; |
| 60 | + |
16 | 61 | import zhao.algorithmMagic.core.AlgorithmStar;
|
17 | 62 | import zhao.algorithmMagic.core.HelpFactory;
|
18 | 63 |
|
|
0 commit comments