// ********************* methods *************************************************** /// <summary> /// Set the current attributes to those belonging to the passed animal. /// </summary> /// <param name="Animal"> /// The passed animal. An ArgumentNullException exception is raised if Animal is /// null. /// </param> public virtual void SetAttributes(cAnimal Animal) { // make sure animal is not null if (Animal == null) { throw new ArgumentNullException("Animal", "Animal must not be null."); } // set values ID = Animal.ID; Age = Animal.Age; YearDied = Animal.YearDied; WeekDied = Animal.WeekDied; Gender = Animal.Gender; ParentID = Animal.ParentID; IsIndependent = Animal.IsIndependent; IsAlive = Animal.IsAlive; Offspring = Animal.Offspring; Cells = Animal.GetCellsAndTime(); Infections = Animal.GetInfections(); Vaccines = Animal.GetVaccines(); Marker = Animal.Marker; AutoMarker = Animal.AutoMarker; CannotGiveBirth = Animal.CannotGiveBirthValue; PartnerMarker = Animal.PartnerMarker; }
/// <summary> /// Determine a contact probability for the animal either in its own cell or to /// all neighbouring cells given an overall contact rate and the current week. /// </summary> /// <param name="CurrentWeek">The current week of the year.</param> /// <param name="Gender"> The Gender of the animal making contact.</param> /// <param name="InCell"> /// True if the contact rate is for within the cell, False if it is for neighbouring cells. /// </param> /// <param name="OverAllContactRate">The overall odds of contact with a single animal.</param> /// <returns>The contact rate either in the cell or with all neighbours.</returns> protected override double getCellContactRate(int CurrentWeek, enumGender Gender, bool InCell, double OverAllContactRate) { // make sure passed week is in range if (CurrentWeek < 1 || CurrentWeek > 52) { ThrowWeekException("CurrentWeek"); } // now calculate required probability // first get male or female probability for outside the cell double ProbValue; if (Gender == enumGender.male) { ProbValue = (this.Background as cFoxBackground).FoxMaleHomeRange[CurrentWeek - 1] / 100.0; } else { ProbValue = (this.Background as cFoxBackground).FoxFemaleHomeRange[CurrentWeek - 1] / 100.0; } // is this in cell or outside cell if (InCell) // we want 1 - the actual value { ProbValue = 1 - ProbValue; } // now multiply by the overall rate return(OverAllContactRate * ProbValue); }
public int GetCountbyAgeGender(int AgeinYear, enumGender Gender) { cAnimalList Animals = this.GetByGender(Gender); int count = 0; foreach (cAnimal anim in Animals) { int AgeInYears = Convert.ToInt32(Math.Floor((double)anim.Age / 52)); //Console.WriteLine("AgeInYears {0} et i {1}", AgeInYears, i); if (AgeInYears == AgeinYear) { count++; } } return(count); }
/// <summary> /// Get a count of all animals of a particular gender. /// </summary> /// <param name="Gender">The gender of interest.</param> /// <returns> /// The count of animals in the list belonging to the desired gender. /// </returns> public int GetCountByGender(enumGender Gender) { int Count = 0; // loop through the entire list adding those animals of the selected gender // to the new list foreach (cAnimal Animal in this) { if (Animal.Gender == Gender) { Count++; } } // return the count return(Count); }
public clsEmployee(int ID, string Code, string Fullname, enumGender Gender, enumCityzone Cityzone, string Username, string Password, enumEmployeeType Employeetype, enumLang Lang, string Pic, clsListHouses Houses = null) { this.ID = ID; this.Fullname = Fullname; this.Gender = Gender; this.Cityzone = Cityzone; this.Code = Code; this.Username = Username; this.Password = Password; this.Employeetype = Employeetype; this.Lang = Lang; this.Pic = Pic; this.Houses = new clsListHouses(); }
/// <summary> /// Get a sub-list of all animals of a particular gender. /// </summary> /// <param name="Gender">The gender of interest.</param> /// <returns>A cAnimalList containing the sub-list.</returns> public cAnimalList GetByGender(enumGender Gender) { // create a new cAnimalList cAnimalList NewList = new cAnimalList(null); // loop through the entire list adding those animals of the selected gender // to the new list. foreach (cAnimal Animal in this) { if (Animal.Gender == Gender) { NewList.Add(Animal); } } // return the newly created list return(NewList); }
// ****************** protected members ******************************************* /// <summary> /// Create a new animal in the passed background. /// </summary> /// <param name="ID">The ID of the new animal.</param> /// <param name="CellID"> /// The ID of the cell containing the new animal. /// </param> /// <param name="Background"> /// The background object that the animal will live in. /// </param> /// <param name="Gender">The gender of the new animal.</param> /// <returns>A reference to the newly created animal.</returns> protected override cAnimal GetNewAnimal(string ID, string CellID, cBackground Background, enumGender Gender) { return(new cRaccoon(ID, CellID, Background, Gender)); }
/// <summary> /// Construct a fox by specifying its ID and Parent. This constructor is /// used when giving birth to new foxes. The background, and initial cell /// are obtained from the parent fox. The year and week of birth are /// obtained from the background that the parent belongs to. /// </summary> /// <param name="ID"> /// The ID of the fox. An ArgumentException exception is raised if the ID has /// zero length. /// </param> /// <param name="Parent"> /// The parent of the fox. An ArgumentNullException exception is raised if /// Parent is null. /// </param> /// <param name="Gender">The gender of the fox.</param> public cFox(string ID, cFox Parent, enumGender Gender) : base(ID, Parent, Gender) { }
// ********************* Constructors ******************************************* /// <summary> /// Construct a fox by specifying its ID, Starting Cell and Background. /// This constructor is used to create the initial foxes in the background. /// All foxes created by this constructor come into existance at year = 0, /// week = 1. Although the foxes created here will start out as juveniles, /// they will have no parents. /// </summary> /// <param name="ID"> /// The ID of the fox. An ArgumentException exception is raised if the ID has /// zero length. /// </param> /// <param name="CellID"> /// The ID of the cell initially occupied by this fox. An ArgumentException /// exception is raised if the cell is not part of the background object to /// which this fox belongs. /// </param> /// <param name="Background"> /// The background object in which the fox lives. An ArgumentNullException /// exception is raised if Background is null. /// </param> /// <param name="Gender"> /// The gender of the fox. /// </param> public cFox(string ID, string CellID, cBackground Background, enumGender Gender) : base(ID, CellID, Background, Gender) { }
// ************************ Protected Members *************************************** /// <summary> /// Create a new animal in the passed background. /// </summary> /// <param name="ID">The ID of the new animal.</param> /// <param name="CellID"> /// The ID of the cell containing the new animal. /// </param> /// <param name="Background"> /// The background object that the animal will live in. /// </param> /// <param name="Gender">The gender of the new animal.</param> /// <returns>A reference to the newly created animal.</returns> protected abstract cAnimal GetNewAnimal(string ID, string CellID, cBackground Background, enumGender Gender);
/// <summary> /// Construct a raccoon by specifying its ID and Parent. This constructor is /// used when giving birth to new raccoons. The background, and initial cell /// are obtained from the parent raccoon. The year and week of birth are /// obtained from the background that the parent belongs to. /// </summary> /// <param name="ID"> /// The ID of the raccoon. An ArgumentException exception is raised if the ID has /// zero length. /// </param> /// <param name="Parent"> /// The parent of the raccoon. An ArgumentNullException exception is raised if /// Parent is null. /// </param> /// <param name="Gender">The gender of the raccoon.</param> public cRaccoon(string ID, cRaccoon Parent, enumGender Gender) : base(ID, Parent, Gender) { }
public User(string firstName, string lastName, enumGender gender) { FirstName = firstName; LastName = lastName; Gender = gender; }