예제 #1
0
 public Node(string pos, List <string> friends)// friends are the neighbouring nodes
 {
     Position   = pos;
     occupied   = false;
     neighbours = friends;
     Cow        = null;
 }
예제 #2
0
 public Player(Phase playerPhase, int unplaced, ICow playerColour)
 {
     this.playerPhase = playerPhase;
     this.unplaced    = unplaced;
     this.placed      = 0;
     this.playerCow   = playerColour;
     HasLost          = false;
 }
예제 #3
0
 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;
 }
예제 #4
0
        public void GiveCowName(string x)
        {
            CowsAlive[0].changePosition(x);
            ICow temp = CowsAlive[0];

            CowsAlive.RemoveAt(0);
            CowsAlive.Add(temp);
        }
예제 #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);
        }
예제 #6
0
        // 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);
        }
예제 #7
0
        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);
        }
예제 #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);
     }
 }
예제 #9
0
        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);
        }
예제 #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);
            }
        }
예제 #11
0
 public void PlaceCow(ICow cow, string position)
 {
     throw new NotImplementedException();
 }
예제 #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();
 }
예제 #13
0
 public void removeCow()
 {
     Cow      = null;
     occupied = false;
 }
예제 #14
0
 public void MillFormed(ICow cow)
 {
     throw new NotImplementedException();
 }
예제 #15
0
 public Milk(ICow cow, IFarmer farmer)
 {
 }
예제 #16
0
 public void addCow(ICow cow)
 {
     Cow      = cow;
     occupied = true;
 }
 public Milk(ICow cow, IFarmer farmer)
 {
 }
 public RoastBeef(IButcher butcher, ICow cow)
 {
 }
예제 #19
0
파일: Salami.cs 프로젝트: kkozmic/PaulTest
 public Salami(IPig pig, ICow cow, IButcher butcher)
 {
 }
예제 #20
0
 public RoastBeef(IButcher butcher, ICow cow)
 {
 }
예제 #21
0
 public void Place(ICow Cow, int Destination)
 {
     Cows[Destination] = Cow;
     UpdateMills();
 }
예제 #22
0
 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));
 }
예제 #23
0
 public Salami(IPig pig, ICow cow, IButcher butcher)
 {
 }