Skip to content

Commit c46718c

Browse files
committed
fix fraction
1 parent 84cb1d2 commit c46718c

File tree

1 file changed

+2
-9
lines changed
  • src/main/kotlin/com/rxmobileteam/lecture2_3/fraction

1 file changed

+2
-9
lines changed

src/main/kotlin/com/rxmobileteam/lecture2_3/fraction/Fraction.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ class Fraction private constructor(
2424
operator fun plus(other: Fraction): Fraction = TODO()
2525

2626
// TODO: "fraction+number" operator
27-
operator fun plus(other: Number): Fraction = TODO()
27+
operator fun plus(other: Int): Fraction = TODO()
2828
//endregion
2929

3030
//region times operators
3131
// TODO: "fraction*fraction" operator
3232
operator fun times(other: Fraction): Fraction = TODO()
3333

3434
// TODO: "fraction*number" operator
35-
operator fun times(number: Number): Fraction = TODO()
35+
operator fun times(number: Int): Fraction = TODO()
3636
//endregion
3737

3838
// TODO: Compare two fractions
@@ -56,12 +56,6 @@ class Fraction private constructor(
5656
//endregion
5757

5858
companion object {
59-
@JvmStatic
60-
fun ofDouble(decimal: Double): Fraction {
61-
// TODO: Returns a fraction from a decimal number
62-
return Fraction(0, 0) // Change this
63-
}
64-
6559
@JvmStatic
6660
fun ofInt(number: Int): Fraction {
6761
// TODO: Returns a fraction from an integer number
@@ -113,7 +107,6 @@ fun main() {
113107
// Creation
114108
println("1/2: ${Fraction.of(1, 2)}")
115109
println("2/3: ${Fraction.of(2, 3)}")
116-
println("1.6: ${Fraction.ofDouble(1.6)}")
117110
println("8: ${Fraction.ofInt(8)}")
118111
println("2/4: ${2 over 4}")
119112

0 commit comments

Comments
 (0)