Skip to content

Commit 3a106a3

Browse files
committed
Removed unnecessary cast in type object. Added goldfish to type object
1 parent 1efa3e7 commit 3a106a3

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

Assets/Patterns/12. Type Object/Animal/Scripts/Animals/Bird.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public Bird(string name, bool canFly)
1313
{
1414
this.name = name;
1515

16-
this.flyingType = canFly ? new ICanFly() as IFlyingType : new ICantFly();
16+
this.flyingType = canFly ? new ICanFly() : new ICantFly();
1717
}
1818

1919
public override void Talk()

Assets/Patterns/12. Type Object/Animal/Scripts/Animals/Fish.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public Fish(string name, bool canFly)
1313
{
1414
this.name = name;
1515

16-
this.flyingType = canFly ? new ICanFly() as IFlyingType : new ICantFly();
16+
this.flyingType = canFly ? new ICanFly() : new ICantFly();
1717
}
1818

1919
public override void Talk()

Assets/Patterns/12. Type Object/Animal/Scripts/Animals/Mammal.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public Mammal(string name, bool canFly)
1313
{
1414
this.name = name;
1515

16-
this.flyingType = canFly ? new ICanFly() as IFlyingType : new ICantFly();
16+
this.flyingType = canFly ? new ICanFly() : new ICantFly();
1717
}
1818

1919
public override void Talk()

Assets/Patterns/12. Type Object/Animal/Scripts/TypeObjectController.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ void Start()
1717

1818
Mammal bat = new Mammal("bat", canFly: true);
1919

20-
Fish flyingFish = new Fish("Flying fish", canFly: true);
20+
Fish flyingFish = new Fish("flying fish", canFly: true);
21+
22+
Fish goldFish = new Fish("goldfish", canFly: false);
2123

2224

2325
ostrich.Talk();
@@ -29,6 +31,8 @@ void Start()
2931
bat.Talk();
3032

3133
flyingFish.Talk();
34+
35+
goldFish.Talk();
3236
}
3337
}
3438
}

0 commit comments

Comments
 (0)