Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

分数で計算できるようにする #18

Open
miyaji255 opened this issue Jun 11, 2022 · 3 comments
Open

分数で計算できるようにする #18

miyaji255 opened this issue Jun 11, 2022 · 3 comments

Comments

@miyaji255
Copy link
Collaborator

分数クラスを作ってそれでより正確な値を計算できるようにする

@miyaji255
Copy link
Collaborator Author

オーバーライドする演算子

Fraction operator +(convariant Fraction other) // 通分して足し算
Fraction operator -(convariant Fraction other) // 通分して引き算
Fraction operator *(convariant Fraction other) // 掛け算
Fraction operator /(convariant Fraction other) // 割り算
Fraction operator ==(convariant Fraction other) // 等しいもの
int get hashCode {
  var result = 3;
  result = 31*result + Numerator;
  result = 31*result + Denominator;
}

@miyaji255
Copy link
Collaborator Author

miyaji255 commented Jun 13, 2022

記法がいくつか間違えてます。vscodeにでてる青い波線に従って修正してください。
例)

Numerator = (Numerator / gcd).toInt(); // X
Numerator ~/= gcd;                     // O

frog3141 added a commit that referenced this issue Jun 13, 2022
@miyaji255
Copy link
Collaborator Author

OKです。pull request出しといてください

miyaji255 added a commit that referenced this issue Jun 15, 2022
miyaji255 added a commit that referenced this issue Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant