Exemplo n.º 1
0
        public void Hit()
        {
            float        power;
            string       output;
            HitEventArgs hargs;

            try
            {
                Console.Write("Is asteroid bigger than ship? (y/n) : ");
                output = Console.ReadLine();

                Console.Write("Enter weight of asteriod: ");
                power = float.Parse(Console.ReadLine());
                hargs = new HitEventArgs(power, output.ToLower() == "y");
            }
            catch
            {
                hargs = new HitEventArgs();
            }

            Console.WriteLine("\nShip is in asteroid belt\n{0} hited by asteroid...\n", this.name);
            if (HitEvent != null)
            {
                HitEvent((SpaceShip)this, hargs);
            }
        }
Exemplo n.º 2
0
 public override void Collapse(SpaceShip e, HitEventArgs hargs)
 {
     Console.WriteLine("Ceres hit the ship " + e.Name);
     if (hargs.Power > 10000 && hargs.isBodySmaller)
     {
         Console.WriteLine(e.Name + " is damaged");
     }
     else
     {
         Console.WriteLine("Hited! Object intact ");
     }
 }
Exemplo n.º 3
0
 abstract public void Collapse(SpaceShip e, HitEventArgs fargs);