TownBuilder, og lidt refactoring
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
using PeopleVille.Location;
|
using PeopleVille.Locations;
|
||||||
|
|
||||||
namespace PeopleVille
|
namespace PeopleVille
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PeopleVille.Location
|
namespace PeopleVille.Locations
|
||||||
{
|
{
|
||||||
public class Bank : Location
|
public class Bank : Location
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PeopleVille.Location
|
namespace PeopleVille.Locations
|
||||||
{
|
{
|
||||||
public class EggStore : Store
|
public class EggStore : Store
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PeopleVille.Location
|
namespace PeopleVille.Locations
|
||||||
{
|
{
|
||||||
public class GunStore : Store
|
public class GunStore : Store
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace PeopleVille.Location
|
namespace PeopleVille.Locations
|
||||||
{
|
{
|
||||||
public abstract class Location
|
public abstract class Location
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using PeopleVille.Equipment;
|
using PeopleVille.Equipment;
|
||||||
|
|
||||||
namespace PeopleVille.Location
|
namespace PeopleVille.Locations
|
||||||
{
|
{
|
||||||
public class Store : Location
|
public class Store : Location
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,15 +12,22 @@ Console.WriteLine("Hello, World!");
|
|||||||
|
|
||||||
|
|
||||||
/* burde i teorien virke?
|
/* burde i teorien virke?
|
||||||
var testCitizen = new AdultCitizen { Name = "", Health = 100 };
|
var testCitizen = new AdultCitizen { Name = "Lars", Health = 100 };
|
||||||
testCitizen.Inventory.Add(new Gun { Name = "Glock", Damage = 50 }); */
|
testCitizen.Inventory.Add(new Gun { Name = "Glock", Damage = 50 }); */
|
||||||
|
|
||||||
/* builder?
|
/* builders? byggemand-bob reference?
|
||||||
var builder = new CitizenBuilder();
|
var cBuilder = new CitizenBuilder();
|
||||||
|
var tBuilder = new TownBuilder();
|
||||||
|
|
||||||
builder
|
cBuilder
|
||||||
.CreateAdult("Lars", 100).WithGun("Glock", 20)
|
.CreateAdult("Lars", 100).WithGun("Glock", 20)
|
||||||
.CreateAdult("Thomas", 100).WithGun("AK", 40).WithFood("Hvid Monster", 0)
|
.CreateAdult("Thomas", 100).WithGun("AK", 40).WithFood("Hvid Monster", 0)
|
||||||
.CreateChild("Troels", 60).WithFood("Apple", 10);
|
.CreateChild("Troels", 60).WithFood("Apple", 10);
|
||||||
|
|
||||||
var borgere = builder.Build(); */
|
tBuilder
|
||||||
|
.AddBank("PeopleVille Bank")
|
||||||
|
.AddGunStore("Gun Store")
|
||||||
|
.AddEggStore("Egg Store");
|
||||||
|
|
||||||
|
var borgere = cBuilder.BuildCitizens();
|
||||||
|
var locations = tBuilder.BuildTown(); */
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using PeopleVille.Equipment;
|
using PeopleVille.Equipment;
|
||||||
|
using PeopleVille.Locations;
|
||||||
using PeopleVille.Persons;
|
using PeopleVille.Persons;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -38,9 +39,37 @@ namespace PeopleVille.WorldBuilder
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Person Build()
|
public Person BuildCitizens()
|
||||||
{
|
{
|
||||||
return person;
|
return person;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class TownBuilder : ITownBuilder
|
||||||
|
{
|
||||||
|
List<Location> locations = new List<Location>();
|
||||||
|
|
||||||
|
public ITownBuilder AddGunStore(string name)
|
||||||
|
{
|
||||||
|
locations.Add(new GunStore { Name = name, Inventory = new Dictionary<object, int>() });
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITownBuilder AddEggStore(string name)
|
||||||
|
{
|
||||||
|
locations.Add(new EggStore { Name = name, Inventory = new Dictionary<object, int>() });
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITownBuilder AddBank(string name)
|
||||||
|
{
|
||||||
|
locations.Add(new Bank { Name = name });
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Location> BuildTown()
|
||||||
|
{
|
||||||
|
return locations;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using PeopleVille.Persons;
|
using PeopleVille.Locations;
|
||||||
|
using PeopleVille.Persons;
|
||||||
|
|
||||||
namespace PeopleVille.WorldBuilder
|
namespace PeopleVille.WorldBuilder
|
||||||
{
|
{
|
||||||
@@ -11,7 +12,10 @@ namespace PeopleVille.WorldBuilder
|
|||||||
|
|
||||||
public interface ITownBuilder
|
public interface ITownBuilder
|
||||||
{
|
{
|
||||||
|
ITownBuilder AddGunStore(string name);
|
||||||
|
ITownBuilder AddEggStore(string name);
|
||||||
|
ITownBuilder AddBank(string name);
|
||||||
|
List<Location> BuildTown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ICitizenBuilder
|
public interface ICitizenBuilder
|
||||||
@@ -20,7 +24,7 @@ namespace PeopleVille.WorldBuilder
|
|||||||
ICitizenBuilder CreateChild(string name, int health);
|
ICitizenBuilder CreateChild(string name, int health);
|
||||||
ICitizenBuilder WithGun(string name, int damage);
|
ICitizenBuilder WithGun(string name, int damage);
|
||||||
ICitizenBuilder WithFood(string name, int healthPoints);
|
ICitizenBuilder WithFood(string name, int healthPoints);
|
||||||
Person Build();
|
Person BuildCitizens();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user