Exemple #1
0
 public Node(string pos, List <string> friends)// friends are the neighbouring nodes
 {
     Position   = pos;
     occupied   = false;
     neighbours = friends;
     Cow        = null;
 }
 public Player(Phase playerPhase, int unplaced, ICow playerColour)
 {
     this.playerPhase = playerPhase;
     this.unplaced    = unplaced;
     this.placed      = 0;
     this.playerCow   = playerColour;
     HasLost          = false;
 }
 public Player(Phase playerPhase, int placed, int unplaced, Cow playerColour)// player constructor
 {
     this.playerPhase = playerPhase;
     this.unplaced    = unplaced;
     this.placed      = placed;
     this.playerCow   = playerColour;
     HasLost          = false;
 }
Exemple #4
0
        public void GiveCowName(string x)
        {
            CowsAlive[0].changePosition(x);
            ICow temp = CowsAlive[0];

            CowsAlive.RemoveAt(0);
            CowsAlive.Add(temp);
        }
Exemple #5
0
        public ICow TakeCow(Color c)
        {
            ICow        cow  = Cows.First(x => x.Color == c);
            List <ICow> list = Cows.ToList();

            list.Remove(cow);
            Cows = list.ToArray();
            return(cow);
        }
        // apply extension method to a custom interface
        public static decimal TotalPrice(this ICow cow)
        {
            decimal price = 0;

            price += cow?.Weight ?? 0;
            price += cow?.MilkVolume() ?? 0;
            price += 1000M;
            return(price);
        }
        private bool CheckMillAgainstBoard(IMill mill, ICow cow)//checks a specified possible mill against a type of cow to see if a mill has been created
        {
            bool       check = true;
            List <int> list  = mill.ToList();

            foreach (int i in list)
            {
                check = check && GetNode(i) == cow;
            }
            return(check);
        }
Exemple #8
0
 public bool Place(int position, IBoard board, IReferee referee, Phase currPhase)
 {
     if (referee.CanPlace(Color, position, currPhase))
     {
         ICow cow = Box.TakeCow(Color);
         board.Place(cow, position);
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public bool CheckIndexForMill(int index, IPlayer player)//Takes a node index and a player to see if that player has a mill from that node
        {
            ICow   cow   = player.GetCow();
            IMills mills = this.mills.GetMillsByIndex(index);

            foreach (Mill mill in mills.GetMills())
            {
                if (CheckMillAgainstBoard(mill, cow))
                {
                    currentMills.Add(mill); return(true);
                }
            }
            return(false);
        }
Exemple #10
0
        public static void MoveCreatesNoDuplicates(int pos, int[] moves)
        {
            foreach (int move in moves)
            {
                IBoard   b   = new Board();
                ICowBox  box = new CowBox();
                IReferee r   = new Referee(b, box);

                b.Place(new Cow(-1, Color.Red), pos);
                b.Move(pos, move);

                ICow oldPosition = b.Occupant(pos);
                Assert.That(oldPosition.Color == Color.Black);
                Assert.That(b.numCowsOnBoard() == 1);
            }
        }
Exemple #11
0
 public void PlaceCow(ICow cow, string position)
 {
     throw new NotImplementedException();
 }
Exemple #12
0
 // Create an array of default cows
 public void initialiseCows()
 {
     Cows = new ICow[24];
     Cows = Cows.Select((x, index) => new Cow(index, Color.Black)).ToArray();
 }
Exemple #13
0
 public void removeCow()
 {
     Cow      = null;
     occupied = false;
 }
Exemple #14
0
 public void MillFormed(ICow cow)
 {
     throw new NotImplementedException();
 }
Exemple #15
0
 public Milk(ICow cow, IFarmer farmer)
 {
 }
Exemple #16
0
 public void addCow(ICow cow)
 {
     Cow      = cow;
     occupied = true;
 }
 public Milk(ICow cow, IFarmer farmer)
 {
 }
 public RoastBeef(IButcher butcher, ICow cow)
 {
 }
Exemple #19
0
 public Salami(IPig pig, ICow cow, IButcher butcher)
 {
 }
Exemple #20
0
 public RoastBeef(IButcher butcher, ICow cow)
 {
 }
Exemple #21
0
 public void Place(ICow Cow, int Destination)
 {
     Cows[Destination] = Cow;
     UpdateMills();
 }
 public void SetNode(int index, ICow cow)// sets the value of a node to the given cow value
 {
     nodes[index] = cow ?? throw new ArgumentOutOfRangeException(nameof(index));
 }
Exemple #23
0
 public Salami(IPig pig, ICow cow, IButcher butcher)
 {
 }