8000 Revert "Add readable behaviour and books + some minor changes" · EpicSharpCode/StrategyExample@b912864 · GitHub
[go: up one dir, main page]

Skip to content

Commit b912864

Browse files
committed
Revert "Add readable behaviour and books + some minor changes"
This reverts commit e0f2ca0.
1 parent e0f2ca0 commit b912864

File tree

16 files changed

+23
-165
lines changed

16 files changed

+23
-165
lines changed

StrategyExample/Item/Behaviours/Books/IReadable.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

StrategyExample/Item/Behaviours/Books/NotReadable.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

StrategyExample/Item/Behaviours/Books/Readable.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

StrategyExample/Item/Behaviours/Food/Eatable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Text;
55
using System.Threading.Tasks;
66

7-
namespace StrategyExample.Item.Behaviours
7+
namespace StrategyExample.Item
88
{
99
internal class Eatable : IEatable
1010
{

StrategyExample/Item/Behaviours/Food/IEatable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Text;
55
using System.Threading.Tasks;
66

7-
namespace StrategyExample.Item.Behaviours
7+
namespace StrategyExample.Item
88
{
99
public interface IEatable
1010
{

StrategyExample/Item/Behaviours/Food/NotEatable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Text;
55
using System.Threading.Tasks;
66

7-
namespace StrategyExample.Item.Behaviours
7+
namespace StrategyExample.Item
88
{
99
public class NotEatable : IEatable
1010
{

StrategyExample/Item/Books/BurntBook.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

StrategyExample/Item/Books/EatableBook.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

StrategyExample/Item/Books/TheWhaleBook.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

StrategyExample/Item/Food/RottenApple.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using StrategyExample.Item.Behaviours;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using System.Linq;
54
using System.Text;

StrategyExample/Item/Food/Tomato.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using StrategyExample.Item.Behaviours;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using System.Linq;
54
using System.Text;

StrategyExample/People/Inventory.cs renamed to StrategyExample/Item/Inventory.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
using StrategyExample.Item;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using System.Linq;
54
using System.Text;
65
using System.Threading.Tasks;
76

8-
namespace StrategyExample.People
7+
namespace StrategyExample.Item
98
{
109
public class Inventory
1110
{

StrategyExample/Item/ItemBase.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using StrategyExample.Item.Behaviours;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using System.Linq;
54
using System.Text;
@@ -12,28 +11,23 @@ public class ItemBase
1211
public string name { get; set; }
1312
public float selfcost { get; set; }
1413

15-
IEatable eatableBehaviour;
16-
IReadable readableBehaviour;
14+
public IEatable eatableBehaviour;
1715

18-
public ItemBase()
19-
{
20-
SetEatableBehaviour(new NotEatable());
21-
SetReadableBehaviour(new NotReadable());
22-
}
16+
public ItemBase() { }
2317

24-
public ItemBase(string _name, float _selfcost) : base()
18+
public ItemBase(string _name, float _selfcost)
2519
{
2620
name = _name;
2721
selfcost = _selfcost;
22+
23+
SetEatableBehaviour(new NotEatable());
2824
}
2925

3026
public void SetEatableBehaviour(IEatable ieatable) => eatableBehaviour = ieatable;
31-
public void SetReadableBehaviour(IReadable ireadable) => readableBehaviour = ireadable;
3227
public void TryEat() { Console.WriteLine($"I try to eat \"{name}\""); eatableBehaviour.Eat(); }
33-
public void TryRead() { Console.WriteLine($"I try to read \"{name}\""); readableBehaviour.Read(); }
3428
public void Examine() {
3529
string eatableState = eatableBehaviour.GetType().Equals(new Eatable().GetType()) ? "eatable" : "not eatable";
36-
Console.WriteLine($"It's seems to be \"{name}\", it's selfcost is {selfcost} and it's {eatableState}"); }
30+
Console.WriteLine($"It's seems to be \"{name}\" and it's {eatableState}"); }
3731

3832
}
3933
}

StrategyExample/People/PeopleBase.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Text;
66
using System.Threading.Tasks;
77

8-
namespace StrategyExample.People
8+
namespace StrategyExample
99
{
1010
public class PeopleBase
1111
{
@@ -18,11 +18,9 @@ public PeopleBase(string _name, DateTime _birthday, int _inventoryCapacity)
1818
{
1919
name = _name;
2020
birthday = _birthday;
21-
ShowInfo();
21+
Console.WriteLine($"I am {name}. My birthday {birthday.ToString("d")}");
2222

2323
inventory = new Inventory(_inventoryCapacity);
2424
}
25-
26-
public void ShowInfo() => Console.WriteLine($"I am {name}. My birthday is {birthday.ToString("d")}.");
2725
}
2826
}

StrategyExample/Program.cs

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using StrategyExample.Item;
2-
using StrategyExample.People;
32
using System;
43
using System.Collections.Generic;
54
using System.Linq;
@@ -15,36 +14,16 @@ internal class Program
1514
public static void Main(string[] args)
1615
{
1716
characters.Add(new PeopleBase("Leo", new DateTime(1997, 10, 15), 10));
18-
var man = characters.Last();
19-
OutputEmptyLine();
17+
var man = characters[0];
18+
2019
man.inventory.AddItem(new Tomato());
21-
man.inventory.items.Last().Examine();
22-
man.inventory.items.Last().TryEat();
23-
man.inventory.items.Last().TryRead();
24-
OutputEmptyLine();
20+
man.inventory.items[0].Examine();
21+
man.inventory.items[0].TryEat();
2522
man.inventory.AddItem(new RottenApple());
26-
man.inventory.items.Last().Examine();
27-
man.inventory.items.Last().TryEat();
28-
man.inventory.items.Last().TryRead();
29-
OutputEmptyLine();
30-
man.inventory.AddItem(new BurntBook());
31-
man.inventory.items.Last().Examine();
32-
man.inventory.items.Last().TryEat();
33-
man.inventory.items.Last().TryRead();
34-
OutputEmptyLine();
35-
man.inventory.AddItem(new TheWhaleBook());
36-
man.inventory.items.Last().Examine();
37-
man.inventory.items.Last().TryEat();
38-
man.inventory.items.Last().TryRead();
39-
OutputEmptyLine();
40-
man.inventory.AddItem(new EatableBook());
41-
man.inventory.items.Last().Examine();
42-
man.inventory.items.Last().TryEat();
43-
man.inventory.items.Last().TryRead();
23+
man.inventory.items[1].Examine();
24+
man.inventory.items[1].TryEat();
4425

4526
Console.ReadLine();
4627
}
47-
48-
public static void OutputEmptyLine() => Console.WriteLine();
4928
}
5029
}

StrategyExample/StrategyExample.csproj

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,12 @@
4343
<Reference Include="System.Xml" />
4444
</ItemGroup>
4545
<ItemGroup>
46-
<Compile Include="Item\Behaviours\Books\IReadable.cs" />
47-
<Compile Include="Item\Behaviours\Books\NotReadable.cs" />
48-
<Compile Include="Item\Behaviours\Books\Readable.cs" />
4946
<Compile Include="Item\Behaviours\Food\Eatable.cs" />
5047
<Compile Include="Item\Behaviours\Food\IEatable.cs" />
51-
<Compile Include="Item\Books\BurntBook.cs" />
52-
<Compile Include="Item\Books\EatableBook.cs" />
53-
<Compile Include="Item\Books\TheWhaleBook.cs" />
5448
<Compile Include="Item\Food\RottenApple.cs" />
5549
<Compile Include="Item\Food\Tomato.cs" />
5650
<Compile Include="Item\Behaviours\Food\NotEatable.cs" />
57-
<Compile Include="People\Inventory.cs" />
51+
<Compile Include="Item\Inventory.cs" />
5852
<Compile Include="Item\ItemBase.cs" />
5953
<Compile Include="People\PeopleBase.cs" />
6054
<Compile Include="Program.cs" />
@@ -63,6 +57,5 @@
6357
<ItemGroup>
6458
<None Include="App.config" />
6559
</ItemGroup>
66-
<ItemGroup />
6760
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6861
</Project>

0 commit comments

Comments
 (0)
0