private void createAnimalButton_Click(object sender, EventArgs e) { SimpleDate birthDate = new SimpleDate(birthdatePickerAnimal.Value.Day, birthdatePickerAnimal.Value.Month , birthdatePickerAnimal.Value.Year); SimpleDate walkDate = new SimpleDate(lastWalkDate.Value.Day, lastWalkDate.Value.Month , lastWalkDate.Value.Year); string selectedAnimal = animalTypeComboBox.SelectedItem.ToString(); if (string.IsNullOrWhiteSpace(animalNameTextBox.Text) || string.IsNullOrEmpty(animalNameTextBox.Text)) { MessageBox.Show("Geef dit arme beestje een naam!"); } if (!string.IsNullOrWhiteSpace(animalNameTextBox.Text)) { string name = animalNameTextBox.Text; if (selectedAnimal == "Cat") { string problems = problemsCatTextBox.Text; AddingCat(name, birthDate, problems); } if (selectedAnimal == "Dog") { AddingDog(name, birthDate, walkDate); } } UpdateListBox(); }
private void AddingDog(string name, SimpleDate date, SimpleDate walk) { int nextnumber = newNumber.Next(maxNumberPets); SimpleDate walkDate = new SimpleDate(walk.Day, walk.Month, walk.Year); if (lastWalkDate.Value.Date == DateTime.Today) { DialogResult result = MessageBox.Show("Was the dog walked today?", "Walk the dog", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { walkDate = walk; } else if (result == DialogResult.No) { walkDate = null; } } else { walkDate = walk; } animal = new Dog(nextnumber, date, name, walkDate); while (!admin.Add(animal)) { int anothernumber = newNumber.Next(maxNumberPets); animal = new Dog(anothernumber, date, name, walkDate); } admin.Add(animal); }
public Animal(int chipRegistrationNumber, SimpleDate dateOfBirth, string name) { ChipRegistrationNumber = chipRegistrationNumber; DateOfBirth = dateOfBirth; Name = name; IsReserved = false; }
private void AddingCat(string name, SimpleDate date, string behaviour) { int nextnumber = newNumber.Next(maxNumberPets); string problems = "no"; if (!string.IsNullOrWhiteSpace(behaviour)) { problems = behaviour; } else { problems = null; } animal = new Cat(nextnumber, date, name, problems); while (!admin.Add(animal)) { int anothernumber = newNumber.Next(maxNumberPets); animal = new Cat(anothernumber, date, name, problems); } admin.Add(animal); }
public Cat(int chipRegistrationNumber, SimpleDate dateOfBirth, string name, string badHabits) : base(chipRegistrationNumber, dateOfBirth, name) { BadHabits = badHabits; }
public Dog(int chipRegistrationNumber, SimpleDate dateOfBirth, string name, SimpleDate lastWalkDate) : base(chipRegistrationNumber, dateOfBirth, name) { LastWalkDate = lastWalkDate; }
public int DaysDifference(SimpleDate date) { TimeSpan timespan = date.date.Subtract(this.date); return(timespan.Days); }