Advertisement
Guest User

Untitled

a guest
Oct 24th, 2015
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Lab3.Step1
  4. {
  5.     abstract class Animal
  6.     {
  7.         public string Name { get; set; }
  8.         public string Breed { get; set; }
  9.         public string Owner { get; set; }
  10.         public string Phone { get; set; }
  11.         public DateTime VaccinationDate { get; set; }
  12.  
  13.         public Animal(string name, string breed, string owner, string phone, DateTime vaccinationDate)
  14.         {
  15.             Name = name;
  16.             Breed = breed;
  17.             Owner = owner;
  18.             Phone = phone;
  19.             VaccinationDate = vaccinationDate;
  20.         }
  21.  
  22.        abstract public bool isVaccinationExpired();
  23.  
  24.        
  25.  
  26.     }
  27. }
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Linq;
  31. using System.Text;
  32. using System.Threading.Tasks;
  33.  
  34. namespace Lab3.Step1
  35. {
  36.     class GuineaPig :Animal
  37.     {
  38.         private static int VaccinationDuration = 6;
  39.         public GuineaPig(string name, string breed, string owner, string phone, DateTime vaccinationDate):base(name,breed,owner,phone,vaccinationDate)
  40.         {
  41.            
  42.         }
  43.  
  44.         public override bool isVaccinationExpired()
  45.         {
  46.             return VaccinationDate.AddMonths(VaccinationDuration).CompareTo(DateTime.Now) > 0;
  47.         }
  48.         public override String ToString()
  49.         {
  50.             return String.Format("Breed: {1,-20} Name: {2,-10} Owner: {3,-10} ({4}) Last vaccination date: {5:yyyy-MM-dd}", Breed, Name, Owner, Phone, VaccinationDate);
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement