首页 > TAG信息列表 > RationalNum
仿照BigDecimal类以面向对象的方式设计有理数类
package Rational; public class RationalNum { private int molecule; private int denominator; public RationalNum(int molecule,int denominator) { this.molecule = molecule; this.denominator = denominator; if(this.denominator==0) { //分母为0时需要强制3.1-互评-OO设计-有理数类的设计
一:给出你的有理数类的代码。 package com.Hellow.java; public class RationalNum { private int mole; //分子 private int denom; //分母 public RationalNum(int m,int d){ this.mole =m; this.denom =d; //函数构造 } public int有理数类的设计
一、有理数类代码 package code; public class RationalNum { private int Numerator;//分子 private int Denominator;//分母 public RationalNum(int Numerator, int Denominator) { //构造函数 this.Numerator=Numerator; this.Denominator=Denominator; } publ