6 kyu

Implement the Fractions class

1,022 of 1,630Dr.RiD

Description:

You are provided with a skeleton of the class Fraction, which accepts two arguments (numerator, denominator).

Your task is to make this class string representable, and addable while keeping the result in the minimum representation possible.

Note: your class should not subclass fractions.Fraction

Example

fraction1 = Fraction(4, 5)
print(fraction1 + Fraction(1, 8))
# outputs: 37/40
Fraction fraction1 = new Fraction(4, 5);
Console.Write(fraction1 + new Fraction(1, 8));
// Outputs: 37/40
fraction1 = fraction 4 5
show (fraction1 + fraction 1 8)
-- outputs: 37/40
Fraction fraction1 = new Fraction(4, 5);
System.out.println(fraction1.add(new Fraction(1, 8)));
// Outputs: 37/40

Enjoy!

Fundamentals
Object-oriented Programming

Stats:

CreatedMay 5, 2016
PublishedMay 5, 2016
Warriors Trained3995
Total Skips121
Total Code Submissions10030
Total Times Completed1630
Python Completions1022
C# Completions242
Haskell Completions36
Java Completions359
Total Stars82
% of votes with a positive feedback rating89% of 246
Total "Very Satisfied" Votes198
Total "Somewhat Satisfied" Votes41
Total "Not Satisfied" Votes7
Total Rank Assessments8
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • Dr.RiD Avatar
  • jhoffner Avatar
  • zebulan Avatar
  • suic Avatar
  • xenoexplorator Avatar
  • anter69 Avatar
  • LazyWolf Avatar
  • Blind4Basics Avatar
  • Voile Avatar
  • hobovsky Avatar
  • G_kuldeep Avatar
  • tobeannouncd Avatar
  • saudiGuy Avatar
Ad