Ejemplo n.º 1
0
        //public void Marry(Person spouse)
        //{
        //    if (this.GetAge() < 20 || spouse.GetAge() < 20)
        //    {
        //        throw new Exception();
        //    }
        //    //return new Person();
        //}
        public Family Marry(Person spouse)
        {
            if (this.GetAge() < 20 || spouse.GetAge() < 20)
            {
                throw new Exception();
            }
            if (this.Gender == spouse.Gender)
            {
                throw new Exception();
            }
            Family f = new Family();

            return f;
        }
Ejemplo n.º 2
0
        public Family Marry(Person spouse)
        {
            if (this.GetAge() < 20 || spouse.GetAge() < 20) {
            throw new Exception();
              }
              if (this.Gender == spouse.Gender) {
            throw new Exception();
              }

              Family f = new Family();
              this.Family = f;
              spouse.Family = f;

              if (this.Gender == "M") {
            f.Husband = this;
            f.Wife = spouse;
              }
              else {
            f.Husband = spouse;
            f.Wife = this;
              }

              return f;
        }
Ejemplo n.º 3
0
 public Family Marry(Person spouse)
 {
     if (this.GetAge() < 20 || spouse.GetAge() < 20)
     {
         throw new Exception();
     }
     else if (this.Gender == spouse.Gender)
     {
         throw new Exception();
     }
     else
     {
         Family f = new Family();
         if (this.Gender.ToLower().Equals("m"))
         {
             f.Name = this.Name + spouse.Name;
             f.Husband = this;
             f.Wife = spouse;
         }
         else
         {
             f.Name = spouse.Name + this.Name;
             f.Husband = spouse;
             f.Wife = this;
         }
         this.Family = f;
         spouse.Family = f;
         return f;
     }
 }