Пример #1
0
        // Helper Methods

        // In essence, this method adds the argument slip to the slipsArr.
        public void UpdateSlipsArr(Slip slip)
        {
            if (slipsArr != null)
            {
                // Create an array that is 1 more than the old array.
                Slip[] tempSlipsArr = new Slip[slipsArr.Length + 1];

                // Make the references of the temporary array equal to the actual array.
                for (int i = 0; i < slipsArr.Length; i++)
                {
                    tempSlipsArr[i] = slipsArr[i];
                }

                // Make the last new additional slip refer to the argument passed.
                tempSlipsArr[slipsArr.Length] = slip;

                //
                slipsArr = tempSlipsArr;
            }
            else
            {
                slipsArr    = new Slip[1];
                slipsArr[0] = slip;
            }
        }
        public bool AssignBoatToSlip(Slip slip)
        {
            if (slip == null ||
                slip.MyBoat != null ||
                slip.Length < Length)
            {
                return(false);
            }

            // Kind of like the else...
            slip.MyBoat = this;
            return(true);
        }
        public override bool Equals(object obj)
        {
            bool isEqual = true;

            if (this.GetType() != obj.GetType())
            {
                isEqual = false;
            }
            else
            {
                Slip tempSlip = (Slip)obj;
                if (SlipId == tempSlip.SlipId)
                {
                    isEqual = true;
                }
                else
                {
                    isEqual = false;
                }
            }

            return(isEqual);
        }
 public void RemoveBoatFromSlip(Slip slip)
 {
     slip.MyBoat = null;
 }