Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Commit

Permalink
interface Calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanPodymov committed Jul 25, 2024
1 parent 42d8ad9 commit 1f2c246
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
12 changes: 1 addition & 11 deletions Calcium/Enums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
import BigNumber
import CalciumCommon

protocol Calculator {
func calculateValue(lhs: String, rhs: String, operation: CalciumCommon.Operation) -> String
}

struct NativeCalculator: Calculator {
class NativeCalculator: CalciumCommon.Calculator {
func calculateValue(lhs: String, rhs: String, operation: CalciumCommon.Operation) -> String {
.init(
operation.calculateValue(
Expand All @@ -24,12 +20,6 @@ struct NativeCalculator: Calculator {
}
}

extension KMMCalculator: Calculator {
func calculateValue(lhs: String, rhs: String, operation: Operation) -> String {
operation.calculateValueKMM(lhs: lhs, rhs: rhs).toPlainString()
}
}

extension CalciumCommon.Digit: CalciumCommon.CalculatorButtonRepresentable {
public var displayingValue: String {
String(value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,12 @@ sealed class CalculatorButton {
class SomeOperation(val operation: Operation) : CalculatorButton()
}

class KMMCalculator {}
interface Calculator {
fun calculateValue(lhs: String, rhs: String, operation: Operation): String
}

class KMMCalculator: Calculator {
override fun calculateValue(lhs: String, rhs: String, operation: Operation): String {
return operation.calculateValueKMM(lhs, rhs).toPlainString()
}
}

0 comments on commit 1f2c246

Please sign in to comment.