Skip to content

Commit

Permalink
class -> struct
Browse files Browse the repository at this point in the history
  • Loading branch information
kingcos committed Dec 7, 2016
1 parent aba4ef6 commit b3a2938
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions 01-Simple_Factory_Pattern.playground/Contents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ protocol Operator {
}

// 遵守协议
class Addition: Operator {
struct Addition: Operator {
var num = (0.0, 0.0)

func getResult() -> Double? {
Expand All @@ -27,15 +27,15 @@ class Subtraction: Operator {
}
}

class Multiplication: Operator {
struct Multiplication: Operator {
var num = (0.0, 0.0)

func getResult() -> Double? {
return num.0 * num.1
}
}

class Division: Operator {
struct Division: Operator {
var num = (0.0, 0.0)

func getResult() -> Double? {
Expand All @@ -53,7 +53,7 @@ enum Operators {
}

// 工厂
enum OperatorFactory {
struct OperatorFactory {
static func calculateForOperator(_ opt: Operators) -> Operator {
switch opt {
case .Addition:
Expand Down

0 comments on commit b3a2938

Please sign in to comment.